Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to make if behave differently

Posted on 2004-08-27
4
Medium Priority
?
199 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 86

Accepted Solution

by:
Mike Tomlinson earned 800 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 80 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 120 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

886 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