|
-
Mar 4th, 2002, 03:30 AM
#1
Thread Starter
Hyperactive Member
What is wrong with SELECT CASE?
Is Select Case code work this way? Although the number is available within the Select Case, it reads only CASE ELSE and prompt me a messagbox according below. What is wrong?
VB Code:
Private Sub txtantdriver_Validate(Cancel As Boolean)
Dim Number As Integer
Select Case Number
Case "1"
txtantdriver.Text = "The Insured."
Case "2"
txtantdriver.Text = "Any other person who is driving on the Insured's order or with his permission."
Case "3"
txtantdriver.Text = "Ant person who is driving on the Insured order or with permission."
Case "4"
txtantdriver.Text = "Any other person provided he is in the PolicyHolder employ is driving on his order or with his permission."
Case "5"
txtantdriver.Text = "Any person provided he is in the PolicyHolder employ and is driving on thier order or with their permission."
Case Else
MsgBox "Case Number not found. Please Try again", vbExclamation, "Case Number"
End Select
-
Mar 4th, 2002, 03:33 AM
#2
Fanatic Member
You are comparing an integer to a string...
Remove the quotes from around the numbers...
Case "1"
Should be
Case 1
Leather Face is comin...
MCSD
-
Mar 4th, 2002, 03:40 AM
#3
Thread Starter
Hyperactive Member
Leather, i did that but i still face the same problem.
-
Mar 4th, 2002, 03:42 AM
#4
Well since you dim the number and then ask it's value wouldn't it be zero and thus be else?
VB Code:
Dim Number As Integer
Select Case Number
Case 0
msgbox Number
End Select
-
Mar 4th, 2002, 03:48 AM
#5
Fanatic Member
-
Mar 4th, 2002, 03:53 AM
#6
Thread Starter
Hyperactive Member
yeah, it is always Zero. So how do i get this work?
-
Mar 4th, 2002, 03:56 AM
#7
Fanatic Member
Eh?
Well you need to retrieve the number from somewhere...
What does the number relate to?
Leather Face is comin...
MCSD
-
Mar 4th, 2002, 04:08 AM
#8
Bouncy Member
i.e.
VB Code:
Private Sub cbxAntDriver_Validate(Cancel As Boolean)
Select Case cbxAntDriver
Case 1:
txtantdriver.Text = "The Insured."
Case 2:
txtantdriver.Text = "Any other person who is driving on the Insured's order or with his permission."
Case 3:
txtantdriver.Text = "Ant person who is driving on the Insured order or with permission."
Case 4:
txtantdriver.Text = "Any other person provided he is in the PolicyHolder employ is driving on his order or with his permission."
Case 5:
txtantdriver.Text = "Any person provided he is in the PolicyHolder employ and is driving on thier order or with their permission."
Case Else
MsgBox "Case Number not found. Please Try again", vbExclamation, "Case Number"
End Select
-
Mar 4th, 2002, 04:18 AM
#9
Thread Starter
Hyperactive Member
Leather,
User has to enter the number in a textbox named txtantdriver.
-
Mar 4th, 2002, 04:24 AM
#10
Fanatic Member
Ok so you need to retrieve the contents of teh text box...
Dim Number as integer
' Check that the user has made a valid entry.
If isNumeric(txtantdriver.Text) = False Then
msgbox "You must enter a number.",vbokonly,"Invalid Input"
txtantdriver.SetFocus
Exit Sub
End if
' Convert the text into an integer.
Number = cInt(txtantdriver.Text)
Select Case Number
etc....
Leather Face is comin...
MCSD
-
Mar 4th, 2002, 04:30 AM
#11
Thread Starter
Hyperactive Member
thanks Leather. darre1, gave me the solution. Try his solution. anyway, tx everyone
-
Mar 4th, 2002, 04:31 AM
#12
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|