Link to home
Start Free TrialLog in
Avatar of santaspores1
santaspores1Flag for United States of America

asked on

vb.net elseif

These questions are about using elseif in visual basic.net.

1.  Is there any difference between elseif and else if ?
2.  If I have elseif (conditionA and conditionB) is it possible that conditionB is tested in the case that conditionA is false?  For example, if the testing of conditionB will cause a runtime error in the case that conditionA is false is it possible for this elseif statement to cause a runtime error?  Ada has a if (conditionA && conditionB) statement that will insure that the second condition is never tested if the first fails.  Does vb.net have anything like this?

SOLUTION
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of santaspores1

ASKER

1.  vb.net allows both elseif and else if... so do they behave in exactly the same way?
2.  Yes... short circuit is what I was looking for - thanks!  Just to be sure... in vb.net:
if (stringA.text.length > 1 AndAlso conditionB) Then
if conditionB would cause a runtime error if stringA were null... this conditional statement will still work... because conditionB will never be tested unless conditionA is evaluated as True FIRST?
Thank you both - I appreciate the help!
>>because conditionB will never be tested unless conditionA is evaluated as True FIRST?

Right
If stringA.text.length > 1 And conditionB  Then

End If

this means both conditions should be true than this block will run.

Thanks,