Solved

how to make if behave differently

Posted on 2004-08-27
4
189 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now