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!
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
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!"
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..
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>