H
Herfried K. Wagner [MVP]
Lior said:I know that the AndAlso and OrElse statements are short-circuiting And and
Or statements ,
respectively .
Should I always use (I don't like the word "always" ...) AndAlso instead
of And
and OrElse instead of Or ?
Why are And and Or statements remained in VB.NET ? is this for the
people who are migrating from VB6 ?
No! Use 'AndAlso' and 'OrElse' only if calls to both operands are not
mandatory. In addition to that, 'And' and 'Or' are still used to perform
binary operations like setting bits or combinbing bit masks:
\\\
<Flags()> _
Public Enum Styles
Filled = 1
Border = 2
FilledAndBorder = Filled Or Border
End Enum
..
..
..
Dim s As Styles = ...
If (s And Styles.Border) = Styles.Border Then
MsgBox("Border is set.")
End If
///
Plus , I have a question about Set data type . As I know , there's no Set
data type (as in Pascal) in VB.NET
(maybe in Visual Basic 2005?) . I'll give an example why do I need the
Set data type for :
I have a program , where there's a special treatment with the numbers
12,13,17,18,19 . So , Instead of write something like : If var=12
Or/OrElse var=13 Or/OrElse var=17
Or/OrElse var=18 Or/OrElse var=19 Then... (Or/OrElse means either Or or
OrElse) .
As you can see here , I deal with 5 numbers - 12,13,17,18,19 - but what
if I had 20 numbers or more to
deal with ?
VB.NET doesn't provide intrinsic support for set operations. However, it's
easy to implement basic set operations using VB.NET:
<URL:http://www.google.to/[email protected]>