If between two numbers

Fox

Active Member
Licensed User
Longtime User
How can i make an if statement between to numbers... I mean if i have an number for example 6 and would say if the calculatet number is between 6.0 and 7.0 then... how can i code this...
 

Cableguy

Expert
Licensed User
Longtime User
you can use : if x>6.0 or x<7.1 then
 
Upvote 0

Fox

Active Member
Licensed User
Longtime User
You would have to change the 'Or' to 'And' there to ensure the number is both above 6 and below 7, rather than either.

B4X:
If x >= 6 AND x <= 7 Then

hmmm this works not at me:

If lbl_hc.Text <= 6 Then
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "en.png")
Else If lbl_hc.Text >= 6 AND <= 7 Then
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "au.png")
Else If lbl_hc.Text >= 7 AND <= 9 Then
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "la.png")
Else If lbl_hc.Text >= 9 AND <= 20 Then
ImageView1.Bitmap = LoadBitmap(File.DirAssets, "ot.png")
End If

gets me follow error:
Compiling code. Error
Error compiling program.
Error description: Missing parameter.
Occurred on line: 630
Else If lbl_hc.Text >= 6 AND <= 7 Then
Word: and
 
Upvote 0

Fox

Active Member
Licensed User
Longtime User
After the 'AND' you need to rewrite the condition e.g

B4X:
Else If lbl_hc.Text >= 6 AND <= 7 Then

becomes:

B4X:
Else If lbl_hc.Text >= 6 AND lbl_hc.Text <= 7 Then

ohhh that works thank you ... ahhh first i have make it then not... ohhh the error with an simple logic error...
 
Upvote 0
Top