|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
There is no conditional And in VB?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 marcwent***@hotmail.com wrote in news:1163579254.040009.272050
@i42g2000cwa.googlegroups.com: > To my surprise Visual Studio 8 - VB evaluates C_B in You could use:> > 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? AndAlso or OrElse 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/archive/2003/08/18/179.aspx regards Michel Posseth [MCP] Show quoteHide quote "marcwent***@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 > > 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. -- Show quoteHide quoteDavid 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 "marcwent***@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 > > 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 usethem in C++ or C#, and I thought And then should be &&.... Thanks!! 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 <marcwent***@hotmail.com> schreef in bericht Show quoteHide quote 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? > > I am presently working in VS 8 / .NET 2005 > > Marc Wentink > 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. Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:uXtrc4OCHHA.4764@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 > > <marcwent***@hotmail.com> schreef in bericht > 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? > > > > I am presently working in VS 8 / .NET 2005 > > > > Marc Wentink > > > > > 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. AndAlso and OrElse were introduced in Visual Basic .NET 2002 (VB7.0).
----- Tim Patrick Start-to-Finish Visual Basic 2005 Show quoteHide quote > 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. > |
|||||||||||||||||||||||