Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Select Case statement not working - simple

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,2014
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Select Case statement not working - simple
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Select Case statement not working - simple - 2/9/2005 3:22:29 AM   
  glennweb

 

Posts: 1
Score: 0
Joined: 2/9/2005
From:
Status: offline
This is my code..

Dim myArray
myArray = Split(sResponse,",")
For I = LBound(myArray) To UBound(myArray)
response.write("Value"&i&": "&myArray(i)&"...<br>")
Next

Select Case myArray(0)
Case "Error"
Welcome = "Transaction error"
Case "Approved"
Welcome = "Transaction approved"
Case "Declined"
Welcome = "Transaction declined"
Case Else
Welcome = "There was another error!"
End Select

response.write("<b>"&Welcome&"</b>")
'response.write(myArray(0))
Response.Write "</html></body>"

the page renders out like this..

Value0: Error...
Value1: 10101...
Value2: 09/02/2005...
Value3: 18:06:17 PM...
Value4: 0...
Value5: ...
Value6: 0.00...
There was another error!.

Now.. if Value0 of my array is "error" then y is the "Select case" function not displaying "Transaction error" as apposed to "There was another error!"
 
 
Post #: 1
 
 Re: Select Case statement not working - simple - 2/9/2005 5:00:03 AM   
  Stew312

 

Posts: 3
Score: 0
Joined: 2/7/2005
From:
Status: offline
I tried your code and got it to work when using it like this:


      

Output was:

Value0: Error...
Value1: test...
Transaction error
----------------------------

Could it be how the array is defined? try: dim myArray() and go from there.. as far as I know you need the '()' if its a dynamically resizing array, although the outputs seem correct when you loop through.. hm.. good luck..

(in reply to glennweb)
 
 
Post #: 2
 
 Re: Select Case statement not working - simple - 2/27/2005 5:02:47 AM   
  cadaha

 

Posts: 3
Score: 0
Joined: 2/27/2005
From:
Status: offline
You don't need parenthesis when declaring an array if you use split to populate it.

This code works, copy and paste

<!--code-->
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%Dim myArray
sResponse = "Error,10101,09/02/2005,18:06:17 PM,0...,...,0.00.."
myArray = Split(sResponse,",")
For I = 0 To UBound(myArray)
response.write("Value"&i&": "&myArray(i)&"...<br>")
Next

Select Case myArray(0)
Case "Error"
Welcome = "Transaction error"
Case "Approved"
Welcome = "Transaction approved"
Case "Declined"
Welcome = "Transaction declined"
Case Else
Welcome = "There was another error!"
End Select
%>
</head>
<body>

<%response.write("<b>"&Welcome&"</b>")
'response.write(myArray(0))
Response.Write "</body></html>"%>
<!--end Code-->

(in reply to glennweb)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Select Case statement not working - simple Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts