I know that you are not to do my homework for me, but I've tried everything, EVERYTHING!
I am new to programming, and now I've started using the if-then-else function, but trying to make a little code just won't work.
Here is the code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim age As Integer
age = txtAge.Text
If age <= 17 Then
MsgBox("Young.")
ElseIf age <= 66 Then
MsgBox("Adult.")
ElseIf age <= 149 Then
MsgBox("Old.")
MsgBox("And retired.")
Else
MsgBox("You can only write numbers in the text-field.")
End If
End Sub
End Class
I've tried to change the Dim age to string, boolean and integer, but it's still the same, I still get the same error message, as it won't get past the first test - in this case, the [If age <= 17 Then] - it crashes.
I've tried to set the Else-message on the top, but I still can't get it to work. I've used several hours to make it work, but I just can't...
It's only a tiny part of my homework, but I've re-read my lecture several times, and checked on other sites, and it's supposed to work!
Please help!!
This post has been edited by Martyr2: 17 February 2013 - 04:52 PM
Reason for edit:: Fixed code tags, Remember it is [code]code here[/code] :)

New Topic/Question
Reply



MultiQuote





|