Lanc1988 Posted February 18, 2004 Posted February 18, 2004 In my button code I want to add an "IF" statement so that If the label is between the numbers 1 through 5 it will show text in another label. The problem is, i cant seem to figure out how to do the 1 through 5 part. I have tried: IF TextBox1.Text (1:5) Then Label1.Text = "You are between 1 and 5" End IF Quote
*Experts* Bucky Posted February 18, 2004 *Experts* Posted February 18, 2004 First you need to convert the Text, which is a string, into a number that can be compared numerically. Then use a combination of the greater-than (>) and less-than (<) operators to check for betweenness. Dim value As Integer value = Convert.ToInt32(TextBox1.Text) ' Convert to Integer If value > 1 And value < 5 Then Label1.Text = "You are between 1 and 5" End if If you want it to be between 1 and 5 inclusive, then use the >= and <= operators, instead. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.