By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,327 Members | 1,096 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,327 IT Pros & Developers. It's quick & easy.

There is no conditional And in VB?

P: n/a
To my surprise Visual Studio 8 - VB evaluates C_B in

if C_A And C_B Then

And Hence if C_B is an expression that can only be validated if C_A is
true my code crashes. For example

If p_EdType <"" And CLng(p_EdType) 0 Then .....

There is no Conditional-And operator in Visual Basic?

I am presently working in VS 8 / .NET 2005

Marc Wentink

Nov 15 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
ma*********@hotmail.com wrote in news:1163579254.040009.272050
@i42g2000cwa.googlegroups.com:
To my surprise Visual Studio 8 - VB evaluates C_B in

if C_A And C_B Then

And Hence if C_B is an expression that can only be validated if C_A is
true my code crashes. For example

If p_EdType <"" And CLng(p_EdType) 0 Then .....

There is no Conditional-And operator in Visual Basic?
You could use:

AndAlso or OrElse

Nov 15 '06 #2

P: n/a
Huh ....:-| surprise ? it is just using the wrong operator in the wrong
situation .

And / Or are are essentially bitwise operators , it is not possible to
support short-circuiting behaviors when doing logical AND and OR operations.

That is why we ( VB 2005 proggers ) have the Andalso / Orelse statements
who do use short circuit behavior so we may use both flavors when it is
apropriate to do so ( bitwise or logical )

for more info :

http://www.panopticoncentral.net/arc...08/18/179.aspx
regards

Michel Posseth [MCP]

"ma*********@hotmail.com" wrote:
To my surprise Visual Studio 8 - VB evaluates C_B in

if C_A And C_B Then

And Hence if C_B is an expression that can only be validated if C_A is
true my code crashes. For example

If p_EdType <"" And CLng(p_EdType) 0 Then .....

There is no Conditional-And operator in Visual Basic?

I am presently working in VS 8 / .NET 2005

Marc Wentink

Nov 15 '06 #3

P: n/a
VB short-circuiting logical operators: AndAlso, OrElse
C# short-circuiting logical operators: &&, ||
VB non-short-circuiting logical operators: And, Or
C# non-short-circuiting logical operators: &, |
VB bitwise operators: And, Or
C# bitwise operators: &, |

Note that both VB and C# have non-short-circuiting logical operators. Also
note that in both VB and C# some operators are overloaded to be both bitwise
and non-short-circuiting logical operators.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
"ma*********@hotmail.com" wrote:
To my surprise Visual Studio 8 - VB evaluates C_B in

if C_A And C_B Then

And Hence if C_B is an expression that can only be validated if C_A is
true my code crashes. For example

If p_EdType <"" And CLng(p_EdType) 0 Then .....

There is no Conditional-And operator in Visual Basic?

I am presently working in VS 8 / .NET 2005

Marc Wentink

Nov 15 '06 #4

P: n/a
Marc,

Do you mean with Visual Studio 8 the version 2003.

There was a Visual Studio 6 and after that the versions VS 2002, VS2003 and
VS2005.

Beside that there are language versions from VB named version 7, 7.1 and 8
but that is typical VB numbering and does not exist as a Microsoft product.

Cor

<ma*********@hotmail.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
To my surprise Visual Studio 8 - VB evaluates C_B in

if C_A And C_B Then

And Hence if C_B is an expression that can only be validated if C_A is
true my code crashes. For example

If p_EdType <"" And CLng(p_EdType) 0 Then .....

There is no Conditional-And operator in Visual Basic?

I am presently working in VS 8 / .NET 2005

Marc Wentink

Nov 15 '06 #5

P: n/a
VS 2005 is VS 8. Take a look at the Visual Studio's Help About screen. My
VS 2005 says its version 8.0.50727.42. VB 8 (2005) has the shortcut
conditionals "AndAlso" and "OrElse".

Mike.

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uX**************@TK2MSFTNGP03.phx.gbl...
Marc,

Do you mean with Visual Studio 8 the version 2003.

There was a Visual Studio 6 and after that the versions VS 2002, VS2003
and
VS2005.

Beside that there are language versions from VB named version 7, 7.1 and 8
but that is typical VB numbering and does not exist as a Microsoft
product.
>
Cor

<ma*********@hotmail.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
To my surprise Visual Studio 8 - VB evaluates C_B in

if C_A And C_B Then

And Hence if C_B is an expression that can only be validated if C_A is
true my code crashes. For example

If p_EdType <"" And CLng(p_EdType) 0 Then .....

There is no Conditional-And operator in Visual Basic?

I am presently working in VS 8 / .NET 2005

Marc Wentink




Nov 16 '06 #6

P: n/a

Cor Ligthert [MVP] schreef:
Do you mean with Visual Studio 8 the version 2003.
Well I am trying to port the app to .NET 2005, but it is originally in
..NET 2003.

If AndAlso is new in .NET 2005 I understand why it's not used.

Nov 16 '06 #7

P: n/a

David Anton schreef:
Note that both VB and C# have non-short-circuiting logical operators.
Right! Did not even came to my mind that they exisited! I never use
them in C++ or C#, and I thought And then should be &&....

Thanks!!

Nov 16 '06 #8

P: n/a
AndAlso and OrElse were introduced in Visual Basic .NET 2002 (VB7.0).

-----
Tim Patrick
Start-to-Finish Visual Basic 2005
Cor Ligthert [MVP] schreef:
>Do you mean with Visual Studio 8 the version 2003.
Well I am trying to port the app to .NET 2005, but it is originally in
.NET 2003.

If AndAlso is new in .NET 2005 I understand why it's not used.

Nov 16 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.