VB.net And vs. AndAlso - Overclock.net - An Overclocking Community

Forum Jump: 

VB.net And vs. AndAlso

 
Thread Tools
post #1 of 8 (permalink) Old 01-16-2007, 03:42 PM - Thread Starter
New to Overclock.net
 
guitar22891's Avatar
 
Join Date: Feb 2006
Location: Florida
Posts: 988
Rep: 46 (Unique: 39)
What is the basic difference between And and AndAlso in visual basic. Also what is the difference between Do While...Loop and the Do...Loop While statement?

guitar22891 is offline  
Sponsored Links
Advertisement
 
post #2 of 8 (permalink) Old 01-16-2007, 04:33 PM
New to Overclock.net
 
FrankenPC's Avatar
 
Join Date: Jun 2006
Location: Bay Area
Posts: 5,573
Rep: 372 (Unique: 243)
There is no such thing as a do..loop without escape logic. While/until escape clauses can be declared at the do or the loop command.

The concept of an escapeless do...loop would be something like do while 1=1...loop. Or do...loop until 1>1. Either way, you go into a spin cycle until you explicitly call an exit do command inside the loop.

bruce.gif Previous Member of Team Owners - 1st to hit 200k and 250Kbruce.gif

bruce.gif Previous member of Rough Riders - 1st to hit 300k!!!bruce.gif

Adios everyone! I've been proud to be a member of Owners and Riders.


FrankenPC is offline  
post #3 of 8 (permalink) Old 01-16-2007, 06:49 PM - Thread Starter
New to Overclock.net
 
guitar22891's Avatar
 
Join Date: Feb 2006
Location: Florida
Posts: 988
Rep: 46 (Unique: 39)
Alright, thanks, how about the "And" and "AndAlso".. what is the difference between them?

guitar22891 is offline  
Sponsored Links
Advertisement
 
post #4 of 8 (permalink) Old 01-16-2007, 06:52 PM
New to Overclock.net
 
Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,282
Rep: 643 (Unique: 391)
You can either have the while at the beginning of the loop or the end. With a while at the beginning the loop is not necessarily executed at all (if the while condition is not met when the loop is encountered for the first time)

rabidgnome229 is offline  
post #5 of 8 (permalink) Old 01-17-2007, 08:34 AM
New to Overclock.net
 
stupid's Avatar
 
Join Date: Jan 2006
Location: Minneapolis, MN, USA
Posts: 1,314
Rep: 160 (Unique: 132)
This is a great question, explained pretty well here: http://panopticoncentral.net/articles/919.aspx

but basically, AndAlso only runs the second 'part' of the AND if and only if the first part is true, whereas AND runs both 'parts' of the AND.

ex used in text:

If (Not x Is Nothing) And (x.y = 10) Then

if x is nothing, then the second 'part' would throw an exception, where f you used:

If (Not x Is Nothing) AndAlso (x.y = 10) Then

The second part would never be evaluated. It is known as short-circuiting.

"If there is a god, I hope he has a good excuse"

-Woody Allen
stupid is offline  
post #6 of 8 (permalink) Old 01-17-2007, 11:45 AM
New to Overclock.net
 
FrankenPC's Avatar
 
Join Date: Jun 2006
Location: Bay Area
Posts: 5,573
Rep: 372 (Unique: 243)
Quote:
Originally Posted by stupid View Post
This is a great question, explained pretty well here: http://panopticoncentral.net/articles/919.aspx

but basically, AndAlso only runs the second 'part' of the AND if and only if the first part is true, whereas AND runs both 'parts' of the AND.

ex used in text:

If (Not x Is Nothing) And (x.y = 10) Then

if x is nothing, then the second 'part' would throw an exception, where f you used:

If (Not x Is Nothing) AndAlso (x.y = 10) Then

The second part would never be evaluated. It is known as short-circuiting.

Interesting! Never used AndAlso before.

bruce.gif Previous Member of Team Owners - 1st to hit 200k and 250Kbruce.gif

bruce.gif Previous member of Rough Riders - 1st to hit 300k!!!bruce.gif

Adios everyone! I've been proud to be a member of Owners and Riders.


FrankenPC is offline  
post #7 of 8 (permalink) Old 01-17-2007, 11:50 AM
Retired Staff
 
Join Date: Nov 2006
Location: NJ
Posts: 65,142
Rep: 4426 (Unique: 2045)
Quote:
Originally Posted by stupid View Post
This is a great question, explained pretty well here: http://panopticoncentral.net/articles/919.aspx

but basically, AndAlso only runs the second 'part' of the AND if and only if the first part is true, whereas AND runs both 'parts' of the AND.

ex used in text:

If (Not x Is Nothing) And (x.y = 10) Then

if x is nothing, then the second 'part' would throw an exception, where f you used:

If (Not x Is Nothing) AndAlso (x.y = 10) Then

The second part would never be evaluated. It is known as short-circuiting.
Would AndAlso be the same as a nested if?


Code:
If (Not x Is Nothing) Then
     If (x.y = 10) Then

To answer most of your questions: (1) a fridge cannot cool a PC (2) 64-bit OS for over 3.4GB (3) If a PCIe card fits, it should work (4) Resolution, not screen size (5) Report, not respond to Spam (6) Single-Rail/Non-Modular PSUs are not always better than Multi-Rail/Modular (7) Sequential does not matter as much as random for OS drives (8) Requirements come before hardware for servers

DuckieHo is offline  
post #8 of 8 (permalink) Old 01-17-2007, 03:04 PM
New to Overclock.net
 
FrankenPC's Avatar
 
Join Date: Jun 2006
Location: Bay Area
Posts: 5,573
Rep: 372 (Unique: 243)
Quote:
Originally Posted by DuckieHo View Post
Would AndAlso be the same as a nested if?


Code:
If (Not x Is Nothing) Then
     If (x.y = 10) Then
Yeah...that seems to be the case. AndAlso is just another compressed command structure. Everything is becoming C-ish.

bruce.gif Previous Member of Team Owners - 1st to hit 200k and 250Kbruce.gif

bruce.gif Previous member of Rough Riders - 1st to hit 300k!!!bruce.gif

Adios everyone! I've been proud to be a member of Owners and Riders.


FrankenPC is offline  
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off