Help With Code Please

cdeane

Member
I got a question.

I need a code that dose something like this that will work:

If TextBox1.Text 0 To 14 Then
Textbox2.Text = 1
Else If Textbox1.Text 15 To 29 Then
Textbox2.Text = 2
Else
Textbox2.Text = 3
End If
 
Last edited:

Cableguy

Expert
Licensed User
1st way:

If TextBox1.Text >0 and TextBox1.Text< 14 Then
Textbox2.Text = 1
Else If Textbox1.Text>15 and TextBox1.Text< 29 Then
Textbox2.Text = 2
Else
Textbox2.Text = 3
End If

2nd way:

Select TextBox1.text

case >0 and <14
TextBox2.text=1
case >15 and <29
TextBox2.Text=2
Case >= 30
TextBox2.text=3
End select
 

klaus

Expert
Licensed User
The code should be:
B4X:
If TextBox1.Text >= 0 and TextBox1.Text <= 14 Then
  Textbox2.Text = 1
Else If Textbox1.Text >= 15 and TextBox1.Text <= 29 Then
  Textbox2.Text = 2
Else
  Textbox2.Text = 3
End If
Otherwise you will miss the values 14, 15 and 29

Best regards.
 
Top