Problem with "Else if" and "<" ">" in VB.NET

Asked

Viewed 127 times

1

I’m setting up a small system that if the number entered in the textbox3 is less than 3, appears in the textbox4 an "8%" message, and if it is a number between 4 and 6, it appears in textbox4 "9%". That part of between 4 and 6 I’m not able to do, I tried to put:

textbox3.text > "4" and < "6"...  

but it didn’t work. Here’s my code.

If Val(TextBox3.Text < "3") Then
        TextBox4.Text = "8%"
    ElseIf Val(TextBox3.Text > "6") Then
        TextBox4.Text = "9%"
    End If

1 answer

1


This is to work if only allow 1 digit, if allowing more than 1 may give problem. The statement seems wrong too, I did what was written in the question. There seems to be a logic error too, unless there’s a validation I didn’t see.

If TextBox3.Text < "3" Then
    TextBox4.Text = "8%"
ElseIf TextBox3.Text >= "4" AndAlso TextBox3.Text <= "6" Then
    TextBox4.Text = "9%"
End If

I put in the Github for future reference.

  • That’s just what I needed. Thanks!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.