Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > What's wrong with this Select Case Syntax?

Reply
Thread Tools

What's wrong with this Select Case Syntax?

 
 
Penny
Guest
Posts: n/a
 
      05-13-2005
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.


 
Reply With Quote
 
 
 
 
Roland Hall
Guest
Posts: n/a
 
      05-13-2005
"Penny" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
: 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


 
Reply With Quote
 
 
 
 
Penny
Guest
Posts: n/a
 
      05-13-2005
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:(E-Mail Removed)...
> "Penny" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> : 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
>
>



 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      05-13-2005
"Penny" wrote in message news:42846286$(E-Mail Removed)...
: 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


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      05-13-2005
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"


 
Reply With Quote
 
Kyle Peterson
Guest
Posts: n/a
 
      05-13-2005
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:(E-Mail Removed)...
> "Penny" wrote in message news:42846286$(E-Mail Removed)...
> : 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
>
>



 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      05-13-2005
"Kyle Peterson" wrote in message
news:%(E-Mail Removed)...
: 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


 
Reply With Quote
 
Kyle Peterson
Guest
Posts: n/a
 
      05-13-2005
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:eFOZ8K$(E-Mail Removed)...
> "Kyle Peterson" wrote in message
> news:%(E-Mail Removed)...
> : 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
>
>



 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      05-13-2005
"Kyle Peterson" <(E-Mail Removed)> wrote in message
news:eOAuuR$(E-Mail Removed)...
: 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dim inside Select case executes in any case? aa ASP General 14 04-24-2007 06:24 AM
"Case 1 To 5" in Select case, giving Error!!. Why? Lakshmi Narayanan.R ASP General 10 03-04-2005 01:13 AM
how to case select with case-insensitive string ? Tee ASP .Net 3 06-23-2004 07:40 PM
Possible to turn on/off cookieless sessions dynamically on a case by case basis at run-time? Steve Franks ASP .Net 2 06-10-2004 02:04 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments