Solved

how to make if behave differently

Posted on 2004-08-27
4
193 Views
Last Modified: 2010-04-23


if xxx() AND yyy() then...

Is there any alternative if that does not evaluate the yyy if xxx is false?
0
Comment
Question by:kamleshmistry
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 200 total points
ID: 11915284
If xxx() AndAlso yyy() Then

End If

If xxx() OrElse yyy() Then

End If
0
 
LVL 10

Assisted Solution

by:Clif
Clif earned 20 total points
ID: 11915525
Simple...

If xxx() Then
    If yyy()
        'Only if xxx() and yyy() are true
    End If
End If
0
 
LVL 10

Expert Comment

by:Clif
ID: 11915531
Ok, let's try the proper syntax...

If xxx() Then
    If yyy() Then
        'Only if xxx() and yyy() are true
    End If
End If
0
 
LVL 14

Assisted Solution

by:ptakja
ptakja earned 30 total points
ID: 11915630
AndAlso and OrElse are new keywords in VB.Net that short circuit compound conditionals if a preceding expression evaluates to false.  These can be combined to more than 2 expressions as:

If xxx() AndAlso yyy() AndAlso zzz() Then

End If

In this case the only way zzz get evaluated is if xxx and yyy are both true.

Jeff
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question