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

ASP Select Case Syntax Error (Case Condition)

Hello, I am getting a syntax error
Microsoft VBScript compilation error '800a0400'

Expected statement
line 49
Case 164 To 269
---------------^
(The error references to keyword "To")

Is there anyone know if ASP support the keyword "To"? or it use another keyword to have the case condition in range? I know I can use a comma to form a multi condition, like "Case 164, 165, 166, 167", etc. However, I need a range from 164 to 269 which is alot. Any idea? Thanks.

My code posted as below:
=======================
Select Case number
Case 161
result = "a"
Case 162
result = "b"
Case 164 To 269
result = "c"
Case 276 To 314
result = "d"
Case Else
result = "e"
End Select
Jul 23 '07 #1
4 10919
jhardman
3,406 Expert 2GB
I would have thought VBScript used the exact same syntax for this type of thing as VB. I'll post in the VB forum to see if anyone there sees a problem I'm missing. If you only have 5 or six cases and you can't get the select to work, you might consider trying an unwieldy if...else statement. It will work even though it will be tiresome.

Jared
Jul 23 '07 #2
Killer42
8,435 Expert 8TB
I have recently been surprised to find that VB.Net doesn't seem to support the To keyword, so maybe ASP doesn't either. It certainly does look that way, to judge from your post. After all, how could you possibly have it wrong? Unless you've got some weird characters in there that we can't see, or some Unicode characters that just look like "To". But come on, how likely is that?

One slightly ugly workaround might be to use this syntax (not tested)...

Case Is >= 164 And <= 269

I've probably got that wrong, but you get the idea - try manipulating the Is clause to get around the problem. If all else fails, does ASP support the ElseIf statement? It's very useful for making an extended IF structure that's almost as clean as Select Case, but has the advantage of allowing complex tests. For example, to rewrite your Select Case...

Expand|Select|Wrap|Line Numbers
  1. If number = 161 Then
  2.   result = "a"
  3. ElseIf number = 162 Then
  4.   result = "b"
  5. ElseIf number >= 164 And number <= 269 Then
  6.   result = "c"
  7. ElseIf number >= 276 And number <= 314 Then
  8.   result = "d"
  9. Else
  10.   result = "e"
  11. End If
Jul 24 '07 #3
ilearneditonline
130 Expert 100+
One slightly ugly workaround might be to use this syntax (not tested)...

Case Is >= 164 And <= 269
Tested this and it doesn't work. The only why I know of is....
Expand|Select|Wrap|Line Numbers
  1.  
  2. Select Case number
  3. Case 161 
  4. result = "a"
  5. Case 162 
  6. result = "b"
  7. Case 164, 165, 166, ...
  8. result = "c"
  9. Case 276, 277, 278, ...
  10. result = "d"
  11. Case Else
  12. result = "e"
  13. End Select
  14.  
Jul 25 '07 #4
Killer42
8,435 Expert 8TB
Tested this and it doesn't work. ...
Bummer!

Have you tried ElseIf? It's almost as compact and easy to read, and (if it is supported) wouldn't require huge lists of values.
Jul 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: sam | last post by:
When I run this SQL query: SELECT u.*, o.* FROM users u, orders o WHERE TO_DAYS(o.order_date) BETWEEN TO_DAYS('2003-09-20')-10 AND TO_DAYS('2003-09-20')+10
9
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...
5
by: Anton | last post by:
I have a table of zip codes, some with Canadian zips. I'd like to take a zip code and search for nearby zips. For example: Dim theZip As Integer = textbox1.text ....Parameter.Add(@ziplow,...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
2
by: Marco Lazzeri | last post by:
What about a SELECT syntax like that? SELECT CASE WHEN bar.foo_id IS NULL THEN bar.* ELSE foo.* FROM foo, bar Anyway, I need a SELECT query that gets data from a FIRST TABLE if a specific...
25
by: CJM | last post by:
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...
4
by: Ian Richardson | last post by:
Hi, The function I've put together below is a rough idea to extend a SELECT list, starting from: <body> <form name="bambam"> <select id="fred"> <option value="1">1</option> <option...
2
by: scole954387 | last post by:
Hi, I have a problem. I have written a SQL statement that has a nested select case statement on the 'where' clause to condition the results. ...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.