Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Private Sub Form_Click()
Dim Status As String, TaxRate As Single
Status = UCase(Val(Texta))
Select Case Status
Case "SINGLE"
Label = 0.2
Case "MARRIED"
Label = 0.14
Case "RETIRED"
Label = 0.12
Case Else
Label = "Please try again."
End Select
End Sub

Whenever I add something in the text box, it gives "Please try again.", no matter what the input is. Even if it's "SINGLE", "MARRIED", or "RETIRED".

What I have tried:

I'm new to this stuff, so I just messed around with the code in every way possible, to no avail.
Posted
Updated 17-Dec-17 19:53pm
Comments
Richard Deeming 18-Dec-17 14:18pm    
If you're new to this, and you're not being forced to maintain a legacy application, do yourself a favour and forget VB6. It's been dead for over 15 years!

Instead, get a free copy of Visual Studio Community edition[^], and either start with VB.NET, or jump straight in to C#.

That way, you won't need to unlearn all of the bad habits that VB6 forces on you when you start working in a current language. :)

1 solution

Use the debugger.
Put a breakpoint on the line
VB
Status = UCase(Val(Texta))
and run your program.
When you reach that line, it will stop, and give you control. Look at Texta, then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why. It will allow you to look at exactly what is in Status and that should help you work out why it doesn't match your strings.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900