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

Case statement

I am getting a syntax error on

Select Case Now
Case > "2/2/2004 12:30:00 AM"
response.redirect "votingover.asp"
case else
m=0
End Select
Jul 19 '05 #1
5 4873
Dave wrote:
I am getting a syntax error on

Select Case Now
Case > "2/2/2004 12:30:00 AM"
response.redirect "votingover.asp"
case else
m=0
End Select


You're comparing a date to a string. Date literals need to be delimited by
hash marks (#):
Case > #2/2/2004 12:30:00 AM#

You can also use CDate to do the conversion:

Case > CDate("2/2/2004 12:30:00 AM")

HTH,
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 19 '05 #2
The select case statement in vbscript isn't as versatile as that in VB. Try
this:
Dim sNow
sNow = Now

Select Case True
Case DateValue(sNow) > DateValue("2/2/2004 12:30:00 AM")
Response.Redirect "votingover.asp"
Case Else
Response.Write "fine"
m=0
End Select

Ray at home

"Dave" <da***@helixpoint.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am getting a syntax error on

Select Case Now
Case > "2/2/2004 12:30:00 AM"
response.redirect "votingover.asp"
case else
m=0
End Select

Jul 19 '05 #3
Oops. The error message mislead me. Now if he had told us that the error
message was "syntax error", ...

Of course, this works as well (I tested it this time :-) ):
Select Case True
Case Now > #1/2/2004 12:30:00 AM#

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"

Ray at <%=sLocation%> wrote:
The select case statement in vbscript isn't as versatile as that in
VB. Try this:
Dim sNow
sNow = Now

Select Case True
Case DateValue(sNow) > DateValue("2/2/2004 12:30:00 AM")
Response.Redirect "votingover.asp"
Case Else
Response.Write "fine"
m=0
End Select

Ray at home

"Dave" <da***@helixpoint.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am getting a syntax error on

Select Case Now
Case > "2/2/2004 12:30:00 AM"
response.redirect "votingover.asp"
case else
m=0
End Select


Jul 19 '05 #4
OP: "I am getting a syntax error on..."

;]

Ray at home

"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:uy****************@TK2MSFTNGP09.phx.gbl...
Oops. The error message mislead me. Now if he had told us that the error
message was "syntax error", ...

Of course, this works as well (I tested it this time :-) ):
Select Case True
Case Now > #1/2/2004 12:30:00 AM#

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"

Ray at <%=sLocation%> wrote:
The select case statement in vbscript isn't as versatile as that in
VB. Try this:
Dim sNow
sNow = Now

Select Case True
Case DateValue(sNow) > DateValue("2/2/2004 12:30:00 AM")
Response.Redirect "votingover.asp"
Case Else
Response.Write "fine"
m=0
End Select

Ray at home

"Dave" <da***@helixpoint.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am getting a syntax error on

Select Case Now
Case > "2/2/2004 12:30:00 AM"
response.redirect "votingover.asp"
case else
m=0
End Select


Jul 19 '05 #5
Ray at <%=sLocation%> wrote:
OP: "I am getting a syntax error on..."

:-(

Time for a break. I read "type mismatch".

Maybe my vision was clouded by the comparison of the string to the date ...
but now that I test it, I see that an implicit conversion is done. This:

Select Case True
Case Now > "1/2/2004 12:30:00 AM"

works just as well as this:
Select Case True
Case Now > #1/2/2004 12:30:00 AM#

Sheesh.

Bob

--
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 19 '05 #6

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

Similar topics

26
by: Joe Stevenson | last post by:
Hi all, I skimmed through the docs for Python, and I did not find anything like a case or switch statement. I assume there is one and that I just missed it. Can someone please point me to the...
6
by: deanfamily11 | last post by:
I've set up a case statement to have my program determine where on the Cartesian plane a point the user enters is located. I keep getting the C2051 error when I compile. Any help? #include...
7
by: Shapper | last post by:
Hello, I have a "Select Case MyVar" in which I define the values of an Array according to the value of MyVar. I need to use the Array Values in a Loop after End Select. It seems the Array is...
3
by: mark.irwin | last post by:
Hello all, Have an issue where a redirect pushes data to a page with a select case which then redirects to another page. Problem is the redirect isnt working in 1 case. Code below: strURL =...
12
by: rAinDeEr | last post by:
Hi, I have a table with 2 columns ** CREATE TABLE test (emp_num DECIMAL(7) NOT NULL,emp_name CHAR(10) NOT NULL) and i have inserted a number of records. ** Now, I want to insert a new...
5
by: Frederick Dean | last post by:
Hi,guys! I'm reading Stephen Dewhurst's book "C++ Gotchas"£¬in gothca #7, I meet a weird case: bool Postorder::next() { switch (pc) case START: while (true) if (!child()) { pc = LEAF; return...
1
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...
22
by: John | last post by:
Hi Folks, I'm experimenting a little with creating a custom CEdit control so that I can decide on what the user is allowed to type into the control. I started off only allowing floating point...
9
by: Robbie Hatley | last post by:
Greetings, group. I just found a weird problem in a program where a variable declared in a {block} after a "case" keyword was being treated as having value 0 even though its actual value should...
13
by: Satya | last post by:
Hi everyone, This is the first time iam posting excuse me if iam making any mistake. My question is iam using a switch case statement in which i have around 100 case statements to compare. so...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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,...

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.