If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > select case problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-15-08, 04:24
noamsmadja noamsmadja is offline
Registered User
 
Join Date: Dec 2007
Posts: 21
select case problem

case 1 to 10
do this

isnt it supposed to work?
Reply With Quote
  #2 (permalink)  
Old 01-15-08, 05:25
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Have you tried
Code:
Select Case someVariable
  Case 1 - 10
    Response.Write("1-10")

Or...
Select Case True
  Case (someVariable >= 1 AND someVariable <= 10)
    Response.Write("1-10")
The "TO" keyword is not supported in VBScript.
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 01-15-08, 07:28
noamsmadja noamsmadja is offline
Registered User
 
Join Date: Dec 2007
Posts: 21
ok,

i'll try the first one later. unless it works i'll use an If, i think case True is not tidy.

thx!! (again)
Reply With Quote
  #4 (permalink)  
Old 01-15-08, 07:46
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
I'm not sure the first suggestion will work, but I am sure that the second will.

But you are right, with the second one you might as well use an If!

The point in a case statement is that the case (i.e. someValue) is only evaluated the once and then compared to various conditions until true.
An If statement evaluates the case for each executed line.

So in theory, case statements are more efficient; the exception being Select True.
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 01-15-08, 07:58
noamsmadja noamsmadja is offline
Registered User
 
Join Date: Dec 2007
Posts: 21
took me some time to remember adding End Ifs and Thens. am used to IF{}

i keep seeing this _ line break for coding. ppl use it to break long lines in their code.... for some reason it isnt working for me...

thats how i was trying to do it:

record.source="SELECT * FROM cell1" _
"cell2" _
"cell3" _
"cell4" _
"WHERE etc etc etc"

wt am i doing wrong? else than using SELECT *
Reply With Quote
  #6 (permalink)  
Old 01-15-08, 08:42
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
  1. You're using SELECT * (still!)
  2. Remember our string concatenator?
    You've split multiple strings over multiple lines
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 02-13-08, 05:07
Marvels Marvels is offline
Registered User
 
Join Date: Jul 2003
Location: Amsterdam, Nederland
Posts: 449
Wink little remark

To : is supoted but not in the way written here (i.e. For i = 1 to 10)

Does that SELECT CASE TRUE work ??? hmmm ok
would rather do :
Code:
dim blValue as boolean=TRUE
blValue=myTxt.Visible
SELECT CASE blValue
CASE TRUE
CASE FALSE
(as im writing it down seem logical that it would work.)
but isn't the case allway true then ???
True = true, why would u then have a select case

SQL : Be sure to put a space befor you start a new line i.e.
Code:
 
slSql= "SELECT ID, Name,WHATEVER"  & _
            " , Age ,Sex" & _
            " , Street, No AS [House number]  ,Postalcode"& _
            " FROM MyTable" & _
            " INNER JOIN OTHER TABLE ON MyTable.ID=OTHER.ID" & _
            " WHERE ID < " & MyInputParameter & _
            " ORDER BY NAME"
EDIT : ok,  Georgev was right as usual  ;-)  (was missing an quote and linecontinuation  )
This way you never have to do a "difficult" left/right to see if there is a space at the end
Break the line on each Function
__________________
Greetz Marvels -^.^-
Developments : VB4 Through .Net; Basic; DOS ; CNC ; Sinclair
Databases : SQL Server Through 2005; Access 3 Through 2003 ; Oracle 8 & 9.i ;
OS : Win 3.11 Through XP ; NortonComander ; DOS

Last edited by Marvels; 02-13-08 at 10:01.
Reply With Quote
  #8 (permalink)  
Old 02-13-08, 05:43
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Nice one Marvels


Shame you made a mistake on that last little bit of code though :wink:
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On