santaspores1
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both - I appreciate the help!
>>because conditionB will never be tested unless conditionA is evaluated as True FIRST?
Right
Right
If stringA.text.length > 1 And conditionB Then
End If
this means both conditions should be true than this block will run.
Thanks,
End If
this means both conditions should be true than this block will run.
Thanks,
ASKER
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?