Tuesday, November 08, 2005

OrElse, AndAlso in Visual Basic (VB)

OrElse operator in Visual Basic (VB) is used to short-circuit the evaluation in the if condition. Apparently, in VB the Or operator does not short-circuit the evaluation of the second logical condition if the first condition evaluates to a Boolean true.

AndAlso operator is Visual Basic (VB) is used to short-circuit the evaluation in the if condition. The regular AND operator does not short-circuit the evaluation of the second logical condition if the first condition evaluates to a Boolean false.

I believe, OrElse and AndAlso should always be used in VB instead of regular Or and And we are familiar with. This should improve the performance especially the second logical condition requires a function call or database access to evaluate.

Bottom line:
  • There is no "real" differnce between OrElse and Or in the VB. Both produces the same result when used in place of each other. The OrElse operator should perform better than Or operator.
  • There is no "real" difference between AndAlso and And in the VB. Both produces the same result when used in place of each other. The AndAlso operator should perform better than the regular And operator.

Saturday, November 05, 2005

Visual Studio and Visual SourceSafe Annoyances

Trying to find the SourceSafe history of the codebehind file is very annoying in the visual studio. Every time I hit that history button from the source control toolbar, it displays the history of the aspx file instead of codebehind vb or cs file. So, I have to open the Visual SourceSafe itself, find the codebehind file and do a ctrl+H to find the history of the file. Too much work.

After I add an existing file to my solution, it automatically checks out the file without asking me. So, I have to undo my checkout. As soon as I undo this checkout, the entire solution explorer bar goes up-and-down, up-and-down and up-and-down. I hope these things are corrected in the next versions.