473,385 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

Nov 15 '06 #1
8 1689
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
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
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
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
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

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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: neblackcat | last post by:
Would anyone like to comment on the following idea? I was just going to offer it as a new PEP until it was suggested that I post it here for comment & consideration against PEP 308. I'm far...
1
by: Bob | last post by:
I need to know if there is a better way to construct this SQL statement. (Error handling is omitted) MS SQL Server 2000 Insert into FSSUTmp Select a.acct_no, a.ac_nm, a.ac_type, 10, -1, -1...
28
by: Benjamin Niemann | last post by:
Hello, I've been just investigating IE conditional comments - hiding things from non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide code from IE/Win browsers. I found...
2
by: John Kreps | last post by:
(acc 2002) I've got six unbound text boxes on a subform that has a white background. Each of those six boxes has an expression that when true, will change its background from white to another...
2
by: Von Bailey | last post by:
I have a form where the conditional formatting is set on some fields to bold if certain conditions are met. However, when the conditions are met some of the data that is to bold is either not...
1
by: chris han | last post by:
Hi, all, I'm trying to use Conditional Compilation Statements in my code. using System; #define DEBUG public class MyClass { public static void Main() {
7
by: John Dolinka | last post by:
I have a project of several files with #defines to setup a conditional compile. I would like to put these #defines in a single file and change the conditional compile from this one file with the...
6
by: patrick j | last post by:
Hi I've been testing out the "Conditional Comment" for IE. This is because for my web-site I want to have two style sheets, one for IE 6 and one for other browsers. Thus I hope to have my...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
15
by: Nicholas M. Makin | last post by:
I was just thinking that I understood the conditional operator when I coded the following expecting it to fail: int a= 10, b= 20, c= 0; ((a < b) ? a : b) = c; // a=0 a=20; b= 10; ((a < b) ? a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.