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

Select Case Fails

P: n/a
using vs 2003 ...

This works fine
Select Case 350
Case 300 To 399
Stop
End Select

This fails with no warning
Select Case 520
Case Not 300 To 399
Stop
End Select

Why?

Bob Day
Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi Bob

I suspect the Not is being applied to 300, thus is the same as

Select Case 520
Case (Not 300) To 399
Stop
End Select

Charles
"Bob Day" <Bo****@TouchTalk.net> wrote in message
news:uK*************@TK2MSFTNGP11.phx.gbl...
using vs 2003 ...

This works fine
Select Case 350
Case 300 To 399
Stop
End Select

This fails with no warning
Select Case 520
Case Not 300 To 399
Stop
End Select

Why?

Bob Day

Nov 20 '05 #2

P: n/a
"Bob Day" <Bo****@TouchTalk.net> schrieb
using vs 2003 ...

This works fine
Select Case 350
Case 300 To 399
Stop
End Select

This fails with no warning
Select Case 520
Case Not 300 To 399
Stop
End Select

Why?

"Not 300" is equal to -301. "Not" inverses all bits:
300 = 0000000100101100 => Not 300 = 1111111011010011 = -301

So, "Case Not 300 To 399" is equal to "Case -301 To 399"

Use instead:
select case 520
case 300 to 399
'empty
case else
stop
end select
--
Armin

Nov 20 '05 #3

P: n/a
I don't think the NOT will work. I've tried and haven't been able to do it.
However, you can get the result you want by testing the affirmative and just
not respoding....

Select Case 520
Case 300 to 399
Case Else
'your code here.
End Select

HTH

Bill

If you use 520, it'll ne
"Bob Day" <Bo****@TouchTalk.net> wrote in message
news:uK*************@TK2MSFTNGP11.phx.gbl...
using vs 2003 ...

This works fine
Select Case 350
Case 300 To 399
Stop
End Select

This fails with no warning
Select Case 520
Case Not 300 To 399
Stop
End Select

Why?

Bob Day

Nov 20 '05 #4

P: n/a
Cor
Armin,
"Not 300" is equal to -301. "Not" inverses all bits:

Clever to see that
My compliments
:-)
Cor
Nov 20 '05 #5

P: n/a
Hi Herfried

You didn't have Option Strict On when you wrote that, did you?

How about

Dim i As Integer = 520

Select Case i
Case Is < 300, Is > 399
Stop

End Select

;-)

Charles
"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
Hello,

"Bob Day" <Bo****@TouchTalk.net> schrieb:
This works fine
Select Case 350
Case 300 To 399
Stop
End Select

This fails with no warning
Select Case 520
Case Not 300 To 399
Stop
End Select

Why?


Have a look at the other replies for an explanation.

\\\
Dim i As Integer = 350
Select Case i
Case i < 300 And i > 399
Stop
End Select
///

;-)

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #6

P: n/a
Hi Herfried,

True words are spoken:

Select Case i
Case i < 300 And i > 399

Equals

Select Case i
Case False

Oops! :-)

Regards,
Fergus
Nov 20 '05 #7

P: n/a
Hello,

"Fergus Cooney" <fi******@tesco.net> schrieb:
True words are spoken:

Select Case i
Case i < 300 And i > 399

Equals

Select Case i
Case False

Oops! :-)


Yep... I know, a typo -- see my reply to Charles.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #8

P: n/a
Hello,

"Charles Law" <bl**@thingummy.com> schrieb im Newsbeitrag
news:OH****************@TK2MSFTNGP10.phx.gbl...
Hi Herfried

You didn't have Option Strict On when you wrote that, did you?
Sorry, I was in god mode. I wanted to write:

\\\
Dim i As Integer = 350
Select Case True
Case i < 300 And i > 399
Stop
End Select
///
How about

Dim i As Integer = 520

Select Case i
Case Is < 300, Is > 399
Stop

End Select


;-)

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.