CodexxxToo
CodexxxToo

Reputation: 3

In Visual Studio: Make value of one Textbox result to a value in another Textbox1

Am building a VB project. I have two textboxes:

Textbox1
Textbox2

I want, if the value of textbox1 equals to numbers between 10-20, the textbox2 to automatically display the word "Thanks".

I thought the code will be something like this:

If Textbox1.text = integer("10-20") then
Textbox2.text = "Thanks"
End if

But its not working. Do you have any idea how to fix this?

Upvotes: 0

Views: 343

Answers (1)

YowE3K
YowE3K

Reputation: 23974

If you know that Textbox1 contains numbers, but you are just wanting to test whether the values are between 10 and 20, you could do

If CInt(Textbox1.Text) >= 10 AndAlso CInt(Textbox1.Text) <= 20 Then
    Textbox2.Text = "Thanks"
End If

If you first need to check for the presence of numbers, rather than garbage, it gets a little bit messier.

Upvotes: 1

Related Questions