In my code the value of strWebService is initially "2 " (that is the number two followed by a space). I then use trim to eliminate the space:
strWebService = readHtmlPage(strTMQuery)
strWebService = Trim(strWebService)
I then run strWebService through a SELECT statement and it always defaults to ELSE:
Select Case strWebService
Case "0"
pnlLogin.Visible = False
pnlPassengerList.Visible = True
Case "1"
lblLoginError.Text = "Password is wrong...<br /><br />"
lblLoginError.Visible = True
Case "2"
lblLoginError.Text = "E-mail address incorrect or not a valid user...<br /><br />"
lblLoginError.Visible = True
Case Else
lblLoginError.Text = "Unknown Error: " & strWebService & "<br /><br />"
lblLoginError.Visible = True
End Select
What am I doing wrong?
MikeHello -
Perhaps you might want to do a conversion to an integer for the case statement?
good luck
take care
tony
I added the following line before my select statement:
Dim intWebService As Integer = CInt(strWebService)
I then removed the double quotes from my case expressions and ran the code but still got the ELSE statement. VB doesn't require BREAK does it?
did you trying doing a response.Write(intWebService) right before the case statement so you can verify the value?
response.write("service =" & strWebService & ".")
Take note of the spaces and period. Should be
service =2.
My code now reads like this (I added the = signs to the label just to make sure the TRIM did its job...)
strWebService = readHtmlPage(strTMQuery)
strWebService = RTrim(strWebService)
Dim intWebService As Integer = CInt(strWebService)lblTest.Text = "=" & intWebService.ToString & "="
lblTest.Visible = TrueSelect Case strWebService
Case 0
pnlLogin.Visible = False
pnlPassengerList.Visible = True
Case 1
lblLoginError.Text = "Password is wrong...<br /><br />"
lblLoginError.Visible = True
Case 2
lblLoginError.Text = "E-mail address incorrect or not a valid user...<br /><br />"
lblLoginError.Visible = True
Case Else
lblLoginError.Text = "Unknown Error: " & strWebService & "<br /><br />"
lblLoginError.Visible = True
End Select
I still get the ELSE... Plus, my label does infact read 2... I don't get what I could be doing wrong...
Your select Statement is still referring to strWebService... Change it to intWebService...
Ha ha, good call. It works. Thanks guys. Strings in SELECT CASE statements SUCK!
0 comments:
Post a Comment