|
-
Apr 12th, 2008, 11:05 PM
#1
Thread Starter
Fanatic Member
[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
-
Apr 12th, 2008, 11:09 PM
#2
Re: check number falls between range
vb.net Code:
Select Case myNumber Case Is <= 10 Case Is <= 20 Case Is <= 30
Etc.
-
Apr 13th, 2008, 12:13 AM
#3
Thread Starter
Fanatic Member
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
-
Apr 13th, 2008, 12:26 AM
#4
Frenzied Member
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
-
Apr 13th, 2008, 01:37 AM
#5
Thread Starter
Fanatic Member
Re: check number falls between range
dear Icyculyr,
thanks for the reply. i will try and get u back
-
Apr 13th, 2008, 07:44 AM
#6
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
-
Apr 13th, 2008, 11:20 AM
#7
Thread Starter
Fanatic Member
Re: check number falls between range
-
Apr 13th, 2008, 12:57 PM
#8
Re: check number falls between range
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|