August 2003 - Posts
If any of you are in the Phoenix, AZ area:
AZIPA (Arizona Internet Professionals Association) sponsors a "Tech Oasis" night once a month in several locations. The downtown Phoenix one is tonight.
I've not been before, but I'm thinking I'll head over tonight (they meet about 150 feet from where I work, so I have NO excuse).
Hope to see some of you there!
I know some of you guys've blogged about KBAlertz, but I just signed up recently and I had to pass it on.
First, the site is run by Dave Wanta, just for all us folks that need to keep up on Microsoft Knowledge Base articles. Check off all the topics you're interested in, and you'll get an email alert anytime Microsoft publishes a new KB or Support article!
Scott Cate mentioned it at the last AZDNUG meeting as one of those tools he can't live without. I totally second that.
Side note: Dave Wanta's coming to AZDNUG September 16. If you live in or near Arizona, I'd get there.
I actually just learned about this a few months ago. I'm sure it's an old .NET technique for some of you out there, but it's one of the simplest things you can do to make your code just a little more efficient.
Basically, if you have a simple if-then statement as follows:
If myInteger=4 And myString=“Hello” then
then your program will check both
myString to see if they match the required values, and then proceed. If you change
AndAlso, your program will first evaluate
myInteger. If it does indeed equal 4, THEN the code will look to
myString to check whether or not it contains “hello”, before it considers running
myInteger is not 4, the if-then block is exited, without ever checking in with
Or statements in the same manner.
It's a simple shortcut that is quickly applied across a large application, which makes your code ever so slightly more efficient.
For more info, check out Mike Farnsworth's article on it.
I heard a short show on this on NPR this morning. It's fascinating.
Basically, it seems, two separate fertilized human embryos which “should” have become fraternal twins, instead fuse together and form one child. This child receives BOTH sets of genes from the two different embryos. Until DNA testing was somewhat common, this went completely undetected. True human Chimeras can pass on either set of genes to their children, while they only have one set specifically in their blood (so paternal blood tests might have false negatives). Or they could leave traces of one set of DNA at a crime scene and have the other set show up in testing.
That page has a link to a recent article in Nature mag, too.
I find myself answering a lot of questions from folks on the forums and various lists about how to raise an event from a user control to the main page it was in. For posterity, I thought I'd post an example to handle a button OnClick event in here:
In your user control, declare a delegate with the relevant arguments & an event to handle it:
Public Delegate Sub delOnclick(ByVal sender As System.Object, ByVal e
Public Event evtOnClick As delOnclick
Add a sub in your user control that handles the button's onclick event, and in the sub raise the event you just created.
Sub btnOnclick(sender as object, system as eventargs) handles
RaiseEvent evtOnclick(sender, e)
And then in your parent page, add code that handles the event in the page load:
AddHandler YourUserControl.evtOnClick, AddressOf TheSubYouWantToCall
That should do it.
Most debugging problems come pretty easily to me for the simple reason that most of the errors I come across are either stupid ones or Google-able. When those fail, I'm pretty much at a loss.
So the last couple of days I've had an issue that failed both of these methods. I was getting a simple “Object reference not set to instance of object” error. I knew I had declared and instantiated everything! Instead of actually dealing with it, I'd work on something else for a little while (”to clear my head”), come back and realize that I'd still declared and instantiated everything, promptly get frustrated because I knew I was missing something really small, and decide I needed time to “clear my head” again. Needless to say, I wasn't getting very far, just more and more frustrated.
Since I couldn't accurately describe my problem, I was hesitant to solicit help. Eventually, I felt I had nowhere else to turn (oh, the drama.) So, I asked around and, getting mostly questions back, started to create a few test pages. Of course, in just trying to recreate the problem, I figured out exactly what it was.
(To sum up:) Lessons learned:
Try recreating the error in the simplest possible manner. It never fails to make your problem completely obvious.
It's something we all know, but I, for one, don't use it nearly enough. So, I'm writing it down to help us all out. :)
OK, I suppose I should have posted this a little earlier, but in response to Scott's “What are you reading?“: