473,321 Members | 1,748 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,321 software developers and data experts.

What's wrong with this Select Case Syntax?

Hi all,

My browser throws this Select Case block back at me pointing out a syntax
error on the line: 'Case < 251', between the word 'Case' and the '<' symbol.

***************************

intWeightTotal = 550

Select Case intWeightTotal
Case < 251
' Do something
Case < 501
' Do something
Case < 1001
' Do something
Case < 2001
' Do something
Case Else
' Do something else
End Select

**************************

All my other Select Case blocks work fine without the '<' symbol.

I've also tried the line 'Case Is < 251' but same error.

Any ideas?

Regards

Penny.
Jul 22 '05 #1
8 3751
"Penny" <pe***@spampolice.com> wrote in message
news:42******@funnel.arach.net.au...
: Hi all,
:
: My browser throws this Select Case block back at me pointing out a syntax
: error on the line: 'Case < 251', between the word 'Case' and the '<'
symbol.
:
: ***************************
:
: intWeightTotal = 550
:
: Select Case intWeightTotal
: Case < 251
: ' Do something
: Case < 501
: ' Do something
: Case < 1001
: ' Do something
: Case < 2001
: ' Do something
: Case Else
: ' Do something else
: End Select
:
: **************************
:
: All my other Select Case blocks work fine without the '<' symbol.
:
: I've also tried the line 'Case Is < 251' but same error.
:
: Any ideas?

Try this:

Select Case True
Case intWeightTotal < 251
' Do something
Case intWeightTotal < 501
' Do something
Case intWeightTotal < 1001
' Do something
Case intWeightTotal < 2001
' Do something
Case Else
' Do something else
End Select

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #2
Thanks Roland,

It now works with your code tip.

All the documentation I could find told me to do it the original way I tried
which is a bit frustrating.

Thanks again!

Regards

Penny.

"Roland Hall" <nobody@nowhere> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
"Penny" <pe***@spampolice.com> wrote in message
news:42******@funnel.arach.net.au...
: Hi all,
:
: My browser throws this Select Case block back at me pointing out a syntax : error on the line: 'Case < 251', between the word 'Case' and the '<'
symbol.
:
: ***************************
:
: intWeightTotal = 550
:
: Select Case intWeightTotal
: Case < 251
: ' Do something
: Case < 501
: ' Do something
: Case < 1001
: ' Do something
: Case < 2001
: ' Do something
: Case Else
: ' Do something else
: End Select
:
: **************************
:
: All my other Select Case blocks work fine without the '<' symbol.
:
: I've also tried the line 'Case Is < 251' but same error.
:
: Any ideas?

Try this:

Select Case True
Case intWeightTotal < 251
' Do something
Case intWeightTotal < 501
' Do something
Case intWeightTotal < 1001
' Do something
Case intWeightTotal < 2001
' Do something
Case Else
' Do something else
End Select

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 22 '05 #3
"Penny" wrote in message news:42********@funnel.arach.net.au...
: Thanks Roland,
:
: It now works with your code tip.
:
: All the documentation I could find told me to do it the original way I
tried
: which is a bit frustrating.
:
: Thanks again!

You're welcome. I hear ya'. I remember searching quite awhile for this
once myself.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #4
Penny wrote:
Hi all,

My browser throws this Select Case block back at me pointing out a
syntax error on the line: 'Case < 251', between the word 'Case' and
the '<' symbol.


That's VB/VBA syntax that does not work in vbscript. It's just one of the
many differences that can be found between the two languages. Unfortunately,
not all these differences are well-documented; however, this one is ...
somewhat. You have to read this article:

Visual Basic for Applications Features Not In VBScript
http://msdn.microsoft.com/library/en...onFeatures.asp
Where you'll find this text in the "Select Case" row:
Expressions containing _Is_ keyword or any comparison operators
Expressions containing a range of values using the To keyword.

Roland already showed you the usual workaround so I won't repeat it here.

You can download an installable version of te WSH documentaion here:
http://tinyurl.com/7rk6

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #5
It's really weird too because this code definetly works and it does not
mention the variable in each case
I have used case statements like in this example for many years now

http://www.powerasp.com/content/code...randomizer.asp

"Roland Hall" <nobody@nowhere> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
"Penny" wrote in message news:42********@funnel.arach.net.au...
: Thanks Roland,
:
: It now works with your code tip.
:
: All the documentation I could find told me to do it the original way I
tried
: which is a bit frustrating.
:
: Thanks again!

You're welcome. I hear ya'. I remember searching quite awhile for this
once myself.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 22 '05 #6
"Kyle Peterson" wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
: It's really weird too because this code definetly works and it does not
: mention the variable in each case
: I have used case statements like in this example for many years now
:
: http://www.powerasp.com/content/code...randomizer.asp

Kyle...

I don't think that's a true comparison to her issue. She's working with
ranges.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #7
you sir are correct
it is different

seems the the variable is needed when using "<" and what not
"Roland Hall" <nobody@nowhere> wrote in message
news:eF**************@TK2MSFTNGP09.phx.gbl...
"Kyle Peterson" wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
: It's really weird too because this code definetly works and it does not
: mention the variable in each case
: I have used case statements like in this example for many years now
:
: http://www.powerasp.com/content/code...randomizer.asp

Kyle...

I don't think that's a true comparison to her issue. She's working with
ranges.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 22 '05 #8
"Kyle Peterson" <kp*****@hotmail.com> wrote in message
news:eO**************@TK2MSFTNGP15.phx.gbl...
: you sir are correct
: it is different
:
: seems the the variable is needed when using "<" and what not

I guess we'll never know why MSFT made it different. It sure adds to the
confusion.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
19
by: Robert Scheer | last post by:
Hi. In VBScript I can use a Select Case statement like that: Select Case X Case 1 to 10 'X is between 1 and 10 Case 11,14,16 'X is 11 or 14 or 16 End Select
1
by: John Hall | last post by:
We need to read a SQL database containing a mix of English words and Chinese Characters. We think we need to use the N'xxxx' to read the Unicode. We have one place where the SELECT statement...
3
by: Matik | last post by:
Hello all, I belive, my problem is probably very easy to solve, but still, I cannot find solution: declare @i int declare @z int create table bubusilala (
4
by: dharmadam | last post by:
update prescriber_cross_ref set preferred_in = 'Y' where prescriber_id = (with temp1 as (select A.prescriber_id,A.prescriber_dea_nb,A.prescriber_ama_nb,A.prescriber_aoa_nb from...
51
by: WindAndWaves | last post by:
Can anyone tell me what is wrong with the goto command. I noticed it is one of those NEVER USE. I can understand that it may lead to confusing code, but I often use it like this: is this...
22
by: MLH | last post by:
I have some audio help files that play fine from within Access 97 and Access 2.0. Both are running on a Windows XP box. But I do not know what program plays the files. If I click Start, Run and...
1
by: cathy | last post by:
UPDATE T1 SET T1.F1 = (SELECT T2.FA from T2 where T1.F2=T2.FB+1 AND T1.F3= T2.FC AND T1.F4= T2.FD
4
by: makinha | last post by:
Hello, I am getting a syntax error Microsoft VBScript compilation error '800a0400' Expected statement line 49 Case 164 To 269 ---------------^ (The error references...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.