[RESOLVED] check number falls between range
hi,
i have 10 combinations as like as follows:
1,10,20,30,40,50,60,70,80,90,100
i have one textbox and one button in my form.if i type 14 in textbox and press the button it should popup "this number falls between 10 to 20. if i type 43 it should popup "this number falls between 40 to 50. like this need to do. using if condition with ">" and "<" operator it can be done . but with out this operator is this possible to do?is there any possiblity to do this? if means please show some example code to do this please
Re: check number falls between range
vb.net Code:
Select Case myNumber
Case Is <= 10
Case Is <= 20
Case Is <= 30
Etc.
Re: check number falls between range
dear jmcilhinney,
this way i know friend, but is there any other way to do this is there any in built function for this if means please share with me
Re: check number falls between range
Try this:
Code:
Dim iValue As Integer = Integer.Parse(MyTextBox.Text) 'Must be only numbers
iValue = iValue Mod 10
If iValue = 1 Then
MessageBox.Show(String.Format("This value is between {0} and {1}", 0, 1))
Else
MessageBox.Show(String.Format("This value is between {0} and {1}", iValue*10, (iValue+1)*10))
End If
Re: check number falls between range
dear Icyculyr,
thanks for the reply. i will try and get u back
Re: check number falls between range
Mod is remainder I think. Try this. It seems to work for the numbers tested with the for - next loop.
Code:
Dim iValue As Integer 'Must be only numbers
For x = 1 To 100
iValue = x
iValue = iValue \ 10
Debug.WriteLine(String.Format("The value {0} is between {1} and {2}", x.ToString, iValue * 10, (iValue + 1) * 10))
Next
Re: check number falls between range
Re: check number falls between range