Solved

how to make if behave differently

Posted on 2004-08-27
4
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

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 …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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