if x not between 1 and 50....

  • Thread starter Thread starter Sven
  • Start date Start date
Sven said:
How can I do that:
if x is not betweend 1 and 50 then...?

I noticed you already received the answer but I'll make a note that you
might want to consider an alternative...

If you "rule" is that a value must not be between 1 and 50 then the code is
a little "better" if it contains that rule. So while you can test for less
than 1 or great than 50 that isn't exactly the rule you describe.

On the other hand the following does:

If Not ((x >= 1) And (x <= 50)) Then...


This isn't a big deal or a "deal" at all but consider expressing the rule in
the code.
Tom
 
Hi Herfried,

Strange

Was you not always saying,

if x <1 OrElse x>50 then

After all the discussions I now see some advantages in it as an extra
logical operator and now you stop using it.

(Because it acts exact as my native language in the same difference with a
single Or )

Cor
 
Cor said:
Hi Herfried,

Strange

Was you not always saying,

if x <1 OrElse x>50 then

After all the discussions I now see some advantages in it as an extra
logical operator and now you stop using it.

:))

Sometimes one "forgets" the new keywords. (but I agree)
 
* "Cor said:
Was you not always saying,

if x <1 OrElse x>50 then

After all the discussions I now see some advantages in it as an extra
logical operator and now you stop using it.

You are right... I should stop working with VB6...

;-)
 
Have you heard the B-E-A-utiful news about Whidbey VB.NET!!!

Using <object>
...
End Using

and

For I As Integer = 1 To 10
If I = 4 Then Continue For
Next I

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
 
Tom,
But I do not see a:

Using With New xxxx
...
End Using

Where I can create an object, apply the With and the Using all in one
statement! The "Using With" statement would combine the "Using" statement
with the "With" statement.

As its not uncommon for me to use:

With New Class1
.x
.y
.z
End With

Just a thought
Jay


Tom Spink said:
Have you heard the B-E-A-utiful news about Whidbey VB.NET!!!

Using <object>
...
End Using

and

For I As Integer = 1 To 10
If I = 4 Then Continue For
Next I

--
HTH,
-- Tom Spink, Über Geek

Woe be the day VBC.EXE says, "OrElse what?"

Please respond to the newsgroup,
so all can benefit
 
Sven said:
How can I do that:

if x is not betweend 1 and 50 then...?

You've already had many, many If-based solutions, but here's
an alternative for you:

Select Case x
Case 1 To 50
' Do Nothing
Case Else
' Do Something
. . .
End Select

Perhaps not as /machine/ efficient but, IMHO, more readible.

HTH,
Phill W.
 
Back
Top