Results 1 to 8 of 8

Thread: [RESOLVED] check number falls between range

  1. #1

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Resolved [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
    Loving dotnet

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: check number falls between range

    vb.net Code:
    1. Select Case myNumber
    2.     Case Is <= 10
    3.  
    4.     Case Is <= 20
    5.  
    6.     Case Is <= 30
    Etc.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    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
    Loving dotnet

  4. #4
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    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

  5. #5

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Re: check number falls between range

    dear Icyculyr,

    thanks for the reply. i will try and get u back
    Loving dotnet

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Re: check number falls between range

    thank you friends
    Loving dotnet

  8. #8
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: check number falls between range

    mark as resolved
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width