I'm getting a syntax error with a Select Case statement:
Select Case CSng(rs.fields("Field1"))
Case 0
Response.Write "Test1"
Case Is < 0 <<< Syntax Error
Response.Write "Test2"
Case Is > 0 <<< Syntax Error
Response.Write "Test3"
End Select
As far as I can tell the syntax *is* correct. What am I missing?
Thanks
Chris 25 4209
> I'm getting a syntax error with a Select Case statement: Select Case CSng(rs.fields("Field1")) Case 0 Response.Write "Test1" Case Is < 0 <<< Syntax Error Response.Write "Test2" Case Is > 0 <<< Syntax Error Response.Write "Test3" End Select
As far as I can tell the syntax *is* correct. What am I missing?
You mean as far as you can tell, aside from the error message telling you
that the syntax is not correct???
I don't know why you're throwing "Is" in there, where did you find syntax
that looked like that?
Here is the documentation for select case: http://msdn.microsoft.com/library/en...71eefb3b01.asp
Personally, I suggest using IF...ELSE...END IF for range vs. exact value.
f1 = CSng(rs.fields("Field1"))
if f1 = 0 then
response.write "Test1"
elseif f1 < 0 then
response.write "Test2"
else
response.write "Test3"
end if
A
"Aaron Bertrand [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:e1**************@TK2MSFTNGP02.phx.gbl... I'm getting a syntax error with a Select Case statement:
Select Case CSng(rs.fields("Field1")) Case 0 Response.Write "Test1" Case Is < 0 <<< Syntax Error Response.Write "Test2" Case Is > 0 <<< Syntax Error Response.Write "Test3" End Select
As far as I can tell the syntax *is* correct. What am I missing? You mean as far as you can tell, aside from the error message telling you that the syntax is not correct???
Yes that's exactly what I mean. Which is why I said it.
'As far as I can tell' means, I haven't found anything to say why it may not
be syntactically correct.
I don't know why you're throwing "Is" in there, where did you find syntax that looked like that?
It's the VB syntax. When '< 0' didn't work, I wondered if the VB syntax was
appropriate.
Here is the documentation for select case:
http://msdn.microsoft.com/library/en...71eefb3b01.asp
Which I'd already reviewed of course... It's a bit sparse, and only
indicates the obvious - that '< 0' or 'Is <0' does not qualify as a valid
expression.
Personally, I suggest using IF...ELSE...END IF for range vs. exact value.
f1 = CSng(rs.fields("Field1")) if f1 = 0 then response.write "Test1" elseif f1 < 0 then response.write "Test2" else response.write "Test3" end if
Of course, this route was always open to me, but I would have rather used
Select Case for clarity.
Elsewhere I have found a comment that '=' is the only comparison operator
allowed in VBScript Select Case statement, and this operator is implicit.
It's not entirely surprising, that VBScript has such shortcomings compared
to VB, but I expected the 'official' sources to make this clear.
CJM
CJM wrote on 30 jun 2006 in microsoft.public.inetserver.asp.general: Elsewhere I have found a comment that '=' is the only comparison operator allowed in VBScript Select Case statement, and this operator is implicit.
Try [if you are sure the field is always a number]:
what = CSng(rs.fields("Field1"))
Select Case true
Case what = 0
Response.Write "Test1"
Case what < 0
Response.Write "Test2"
Case what > 0
Response.Write "Test3"
End Select
I however prefer Aaron's if..elseif..then solution.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
> 'As far as I can tell' means, I haven't found anything to say why it may not be syntactically correct.
To me, 'as far as I can tell' implies that you have found something that
says it should be syntactically correct. But that was just my
interpretation.
It's not entirely surprising, that VBScript has such shortcomings compared to VB, but I expected the 'official' sources to make this clear.
Microsoft isn't too great on documenting the limitations in their products.
Especially ones they aren't actively developing. ;-)
"Aaron Bertrand [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:uS**************@TK2MSFTNGP04.phx.gbl... It's not entirely surprising, that VBScript has such shortcomings compared to VB, but I expected the 'official' sources to make this clear.
Microsoft isn't too great on documenting the limitations in their products. Especially ones they aren't actively developing. ;-)
I realise that this isnt a priority anymore, but I would have expected
better documentation precisely because ASP/VBScript has been such a key
technology over the years. And I'm surprised that more independent sources
didn't list this caveat....
CJM wrote: I realise that this isnt a priority anymore, but I would have expected better documentation precisely because ASP/VBScript has been such a key technology over the years. And I'm surprised that more independent sources didn't list this caveat....
What would you have them document, that incorrect syntax may not produce the
desired results?
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
> What would you have them document, that incorrect syntax may not produce the desired results?
I was wondering what to expect.
Maybe also, "if you are used to switch in JavaScript, here is how those
differ..."
A
>> Which I'd already reviewed of course... It's a bit sparse, and only indicates the obvious - that '< 0' or 'Is <0' does not qualify as a valid expression.
but I expected the 'official' sources to make this clear.
So, the documentation indicates the obvious, but it's not clear???
Bob Lehmann
"CJM" <cj*******@newsgroup.nospam> wrote in message
news:Od**************@TK2MSFTNGP04.phx.gbl... "Aaron Bertrand [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in
message news:e1**************@TK2MSFTNGP02.phx.gbl... I'm getting a syntax error with a Select Case statement:
Select Case CSng(rs.fields("Field1")) Case 0 Response.Write "Test1" Case Is < 0 <<< Syntax Error Response.Write "Test2" Case Is > 0 <<< Syntax Error Response.Write "Test3" End Select
As far as I can tell the syntax *is* correct. What am I missing? You mean as far as you can tell, aside from the error message telling
you that the syntax is not correct???
Yes that's exactly what I mean. Which is why I said it.
'As far as I can tell' means, I haven't found anything to say why it may
not be syntactically correct.
I don't know why you're throwing "Is" in there, where did you find
syntax that looked like that?
It's the VB syntax. When '< 0' didn't work, I wondered if the VB syntax
was appropriate.
Here is the documentation for select case:
http://msdn.microsoft.com/library/en...71eefb3b01.asp
Which I'd already reviewed of course... It's a bit sparse, and only indicates the obvious - that '< 0' or 'Is <0' does not qualify as a valid expression.
Personally, I suggest using IF...ELSE...END IF for range vs. exact
value. f1 = CSng(rs.fields("Field1")) if f1 = 0 then response.write "Test1" elseif f1 < 0 then response.write "Test2" else response.write "Test3" end if
Of course, this route was always open to me, but I would have rather used Select Case for clarity.
Elsewhere I have found a comment that '=' is the only comparison operator allowed in VBScript Select Case statement, and this operator is implicit.
It's not entirely surprising, that VBScript has such shortcomings compared to VB, but I expected the 'official' sources to make this clear.
CJM
Aaron Bertrand [SQL Server MVP] wrote: I was wondering what to expect.
Maybe also, "if you are used to switch in JavaScript, here is how those differ..."
Even if that were the case, the syntax he provided bears no resemblance to
the JScript switch syntax, so I still am left baffled by his expectations.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
"CJM" <cj*******@newsgroup.nospamwrote in message
news:Od**************@TK2MSFTNGP04.phx.gbl...
>
"Aaron Bertrand [SQL Server MVP]" <te*****@dnartreb.noraawrote in
message
news:e1**************@TK2MSFTNGP02.phx.gbl...
I'm getting a syntax error with a Select Case statement:
Select Case CSng(rs.fields("Field1"))
Case 0
Response.Write "Test1"
Case Is < 0 <<< Syntax Error
Response.Write "Test2"
Case Is 0 <<< Syntax Error
Response.Write "Test3"
End Select
As far as I can tell the syntax *is* correct. What am I missing?
You mean as far as you can tell, aside from the error message telling
you
that the syntax is not correct???
Yes that's exactly what I mean. Which is why I said it.
'As far as I can tell' means, I haven't found anything to say why it may
not
be syntactically correct.
I don't know why you're throwing "Is" in there, where did you find
syntax
that looked like that?
It's the VB syntax. When '< 0' didn't work, I wondered if the VB syntax
was
appropriate.
Here is the documentation for select case: http://msdn.microsoft.com/library/en...71eefb3b01.asp
Which I'd already reviewed of course... It's a bit sparse, and only
indicates the obvious - that '< 0' or 'Is <0' does not qualify as a valid
expression.
Personally, I suggest using IF...ELSE...END IF for range vs. exact
value.
f1 = CSng(rs.fields("Field1"))
if f1 = 0 then
response.write "Test1"
elseif f1 < 0 then
response.write "Test2"
else
response.write "Test3"
end if
Of course, this route was always open to me, but I would have rather used
Select Case for clarity.
Elsewhere I have found a comment that '=' is the only comparison operator
allowed in VBScript Select Case statement, and this operator is implicit.
It's not entirely surprising, that VBScript has such shortcomings compared
to VB, but I expected the 'official' sources to make this clear.
CJM
I don't think the documentation is at fault here. There is no assumption in
the documentation that the reader is already familiar with VB thereby
needing guidance as to the differences. The standard definition of an
'expression' is assumed by the documentation. There is nothing there that
implies that the testexpression would form the first operand in any partial
expression in any Case expressionlist. The documentation is not being
'sparse' by not describing things you might think you can do but actually
can't, such documentation would be impossible to read.
Just my pennies worth ;)
The MSDN VB documentation states that 'Case <expressionlist-n>' is the
correct syntax. So does the MSDN VBScript documentation.
I made the incorrect assumption (or perhaps an expectation) that MSDN would
regard these as being the same, when they aren't.
Update: When I was complaining about the documentation being sparse, I've
just realised that most of the information is being hidden, since I was
viewing the page in Firefox. The basic syntax is shown but there are no
accompanying notes. In Opera 9, it doesnt shown anything. Check for
yourselves. [So I'm not going mad after all....]
Having now attempted to view the page in IE6, I can now see the comments
which does indicate that comma-separated expression are allowed...
However, we are back to the argument of the mean of the word 'expression'.
According to the MSDN VB documentation 'Is < 0' is a valid expression... so
why wouldn't it be valid for VBScript? Surely, the limits to the type of
acceptable expressions should be stated? http://foldoc.org/foldoc.cgi?query=e...&action=Search
CJM wrote:
However, we are back to the argument of the mean of the
word 'expression'. According to the MSDN VB documentation
'Is < 0' is a valid expression... so why wouldn't it be
valid for VBScript?
For one thing, VB is not VBScript. And [IS] has a very specific purpose in
VBScript -- the comparison of *objects*: http://msdn.microsoft.com/library/en...3fad510189.asp
Lastly, in VBScript, [IS] requires two operands. Your expression does not
satisfy this requirement.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
"Dave Anderson" <NY**********@spammotel.comwrote in message
news:Os**************@TK2MSFTNGP03.phx.gbl...
>
For one thing, VB is not VBScript. And [IS] has a very specific purpose in
VBScript -- the comparison of *objects*:
Of course VB is not VBScript. I have never indicated anything to the
contrary, but they *are* closely related, so when I couldnt find the
information I wanted for VBScript, I looked for inspiration from VB.
CJM wrote:
"Dave Anderson" <NY**********@spammotel.comwrote in message
news:Os**************@TK2MSFTNGP03.phx.gbl...
For one thing, VB is not VBScript. And [IS] has a very specific purpose in
VBScript -- the comparison of *objects*:
Of course VB is not VBScript. I have never indicated anything to the
contrary, but they *are* closely related, so when I couldnt find the
information I wanted for VBScript, I looked for inspiration from VB.
Not always a bad idea, but given that it didn't work in this case, it
seems pretty pointless complaining that it didn't work, just as it's
pretty pointless complaining that any official documentation doesn't
explicity exclude all the infinite number of possiblities one could
come up with in terms of incorrect syntax.
--
Mike Brind
CJM wrote:
...when I couldnt find the information I wanted for VBScript...
I can certainly appreciate this statement. When looking for the [Select
Case] documentation, I found that it was not listed here... http://msdn.microsoft.com/library/en...4cde3390cb.asp
....yet it is listed among the Statements in the left-pane menu. That's a bad
oversight, IMO.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
"CJM" <cj*******@newsgroup.nospamwrote in message
news:Oc**************@TK2MSFTNGP04.phx.gbl...
The MSDN VB documentation states that 'Case <expressionlist-n>' is the
correct syntax. So does the MSDN VBScript documentation.
I made the incorrect assumption (or perhaps an expectation) that MSDN
would
regard these as being the same, when they aren't.
Update: When I was complaining about the documentation being sparse, I've
just realised that most of the information is being hidden, since I was
viewing the page in Firefox. The basic syntax is shown but there are no
accompanying notes. In Opera 9, it doesnt shown anything. Check for
yourselves. [So I'm not going mad after all....]
Having now attempted to view the page in IE6, I can now see the comments
which does indicate that comma-separated expression are allowed...
However, we are back to the argument of the mean of the word 'expression'.
According to the MSDN VB documentation 'Is < 0' is a valid expression...
so
why wouldn't it be valid for VBScript? Surely, the limits to the type of
acceptable expressions should be stated?
The VB documentation very specifically highlights the special use of the
keyword 'Is' in the context of a Case statement. The VBScript documentation
does not. The VBScript documentation also omits reference to the 'To'
keyword in the context of the Case statement and of course trying to use it
also results in an error. http://foldoc.org/foldoc.cgi?query=e...&action=Search
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11**********************@v61g2000cwv.googlegr oups.com...
>
Not always a bad idea, but given that it didn't work in this case, it
seems pretty pointless complaining that it didn't work, just as it's
pretty pointless complaining that any official documentation doesn't
explicity exclude all the infinite number of possiblities one could
come up with in terms of incorrect syntax.
First of all, I'm not complaining it didn't work; I explicitly said that I
was hoping for inspiration from the VB documentation but that I accepted its
limitations.
Secondly, I expect reserved terms like 'expressionlist' to be consistent
across MSDN especially since the term 'expression' is not an MS-only term. I
don't expect MSDN to detail the infiinite number of terms of incorrect
syntax, but I would hope it would give a better indication of what is and
isn't allowed. The fact is that I wanted to use a valid expression in the
statement (an expression that MS regard as valid for VB) yet it isn't valid
for VBScript, and on top of that, the most important MSDN help was hidden
because of poor web design, so it was difficult to even infer the right
information. More importantly, I geniunely expected VBScript to be able to
handle this kind of expression, and I'm surprised it doesnt. And I'm
surprised I didnt find any 3rd-party websites that remarked on this
situation - I can't be the first person to hope for more out of the Select
Case statement.
What I would complain about (if it were any use) were the ratio of helpful
responses to those that weren't helpful (like yours). I didn't start this
thread to complain about VBScript - I wanted to find out an answer to
satisfy my curiousity. I eventually got that answer, but not before a number
of people tried to sour the thread with their unhelpful answers. If people
put the same amount of effort into helping posters rather than starting
conflict, this NG would be that much better.
The unintentional insight I gained was that the majority of users seem to be
locked into IE as their preferred UA (which surprised me).
CJM
"Dave Anderson" <NY**********@spammotel.comwrote in message
news:ec**************@TK2MSFTNGP05.phx.gbl...
CJM wrote:
>...when I couldnt find the information I wanted for VBScript...
I can certainly appreciate this statement. When looking for the [Select
Case] documentation, I found that it was not listed here... http://msdn.microsoft.com/library/en...4cde3390cb.asp
...yet it is listed among the Statements in the left-pane menu. That's a
bad oversight, IMO.
Dave,
Are you sure? It's listed for me (in both IE & FF). Right column, third from
bottom.
CJM
CJM wrote:
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11**********************@v61g2000cwv.googlegr oups.com...
<snip>
>
What I would complain about (if it were any use) were the ratio of helpful
responses to those that weren't helpful (like yours). I didn't start this
thread to complain about VBScript - I wanted to find out an answer to
satisfy my curiousity. I eventually got that answer, but not before a number
of people tried to sour the thread with their unhelpful answers. If people
put the same amount of effort into helping posters rather than starting
conflict, this NG would be that much better.
I don't accept that as a true reflection of this group. Sometimes
people need the blindingly obvious to be explained, and some posters
will do so in a seemingly abrupt, possibly even a sarcastic way -
although it is impossible to read motivation into a few short words
most of the time.
IMO this NG suffers much less from people deliberately trying to flame
than any other I know of. It hardly ever happens, and I don't see that
it necessarily did in this thread. True, my contribution wasn't
helpful, and was probably better left unposted. If it irritated you, I
apologise.
>
The unintentional insight I gained was that the majority of users seem to be
locked into IE as their preferred UA (which surprised me).
I only use it to look at the online MSDN documentation. Their
silly-arse dhtml doesn't work in Firefox :-)
Nor, incidentally, does this page: http://www.aspfaq.com/categories.asp
.......
--
Mike Brind
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@h44g2000cwa.googlegro ups.com...
>
I only use it to look at the online MSDN documentation. Their
silly-arse dhtml doesn't work in Firefox :-)
You should try it with Opera. Seriously...
Nor, incidentally, does this page: http://www.aspfaq.com/categories.asp
......
Hmmm... the internal category links don't work it appears...
I notice the Aaron is going through a major overhaul, so maybe we should
wait until it settles.
[Aaron: have you gone live yet? The start date was 18/06/06, but it doesn't
look like you've switched over yet]
CJM
CJM wrote:
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@h44g2000cwa.googlegro ups.com...
>> I only use it to look at the online MSDN documentation. Their silly-arse dhtml doesn't work in Firefox :-)
You should try it with Opera. Seriously...
>Nor, incidentally, does this page: http://www.aspfaq.com/categories.asp ......
Hmmm... the internal category links don't work it appears...
I notice the Aaron is going through a major overhaul, so maybe we
should wait until it settles.
[Aaron: have you gone live yet? The start date was 18/06/06, but it
doesn't look like you've switched over yet]
Aaron no longer owns the site, so don't blame him ...
--
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"
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...
Aaron no longer owns the site, so don't blame him ...
--
He's still top of the Credits page, and the Copyright notice is still
against him...
Who is in charge these days?
CJM wrote:
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...
>Aaron no longer owns the site, so don't blame him ... --
He's still top of the Credits page, and the Copyright notice is still
against him...
Who is in charge these days?
I'll let him address this himself. I don't know the details.
--
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"
CJM wrote:
Are you sure? It's listed for me (in both IE & FF). Right column,
third from bottom.
I am no longer sure. I see it now, but looked for it three times yesterday
and did not see it.
[scratches head]
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
I do not know what the holdup is on the new site; like you, I expected to
see it go live June 18th.
As for credits/copyright, well, technically, I still did write the majority
of the content, and put the site together. Just because I no longer run it
administratively does not mean that the content is suddenly credited to
someone else. Part of the deal was (a) all links from Google, etc. will
remain intact no matter what changes they make to the structure of the site,
and (b) I would maintain author credit.
So, some of the slowdown may be attributed to them keeping up their end of
the deal.
Who is in charge these days?
The name(s) of the actual people involved, I'm not at liberty to discuss,
and I don't know what you would get out of that information anyway. If you
have questions or feedback regarding the site, you can continue to use the
feedback page, just like you would have a month ago or 5 years ago. They
may respond slower than I typically did, they may respond faster, I really
don't know. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mohammed Mazid |
last post by:
Hi folks!
Can anyone please help me with this?
I am developing a Quiz program but I am stuck with "multiple answers".
Basically I need some sort of code that would select multiple answers...
|
by: Newbie |
last post by:
Dear friends,
I am having a hard time understanding how to use a SELECT CASE in ASP. I
have used it in VB but never in ASP scripting.
Scenerio:
I have 2 textboxes on a form that I have to...
|
by: Kevin |
last post by:
Hi, I am getting a syntax error
Microsoft VBScript compilation error '800a03ea'
Syntax error
On the code below. The error references the "End Select" line
Can anyone help me with what I am...
|
by: Penny |
last post by:
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.
***************************
...
|
by: MLH |
last post by:
Suppose the following...
Dim A as Date
A=#7/24/2005#
I wish to compare value of A against 2 other values:
1) 8/1/2005
2) 9/1/2005
Which is better and why...
First:
|
by: Lauren Quantrell |
last post by:
Is there any speed/resource advantage/disadvantage in using
Select Case x
Case 1
Case 2
etc. many more cases...
End Select
VS.
|
by: Rob Meade |
last post by:
Ok - I *think* this is only different in .net 2.0 - as I've not had any
problems in the past, but then maybe I've not tried it...
I have a value being read from an xml file where the value maybe...
|
by: |
last post by:
Hello,
This is gonna sound real daft, but how do I test a Select Case statement for
variants of a theme?
Here's a snippet of my code...
Select Case sUsr
Case "Guest", "TsInternetUser",...
|
by: microsoft.public.dotnet.languages.vb |
last post by:
Hi All,
I wanted to know whether this is possible to use multiple variables to
use in the select case statement such as follows:
select case dWarrExpDateMonth, dRetailDateMonth
case...
|
by: tjc0ol |
last post by:
Hi guys,
I'm a newbie in php and I got error in my index.php which is:
1054 - Unknown column 'p.products_id' in 'on clause'
select p.products_image, pd.products_name, p.products_id,...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |