+ Reply to Thread
Results 1 to 3 of 3

Textboxes

  1. #1
    Subs
    Guest

    Textboxes

    Hi All

    I am trying to evaluate two textboxes

    If TextBox3.Value > TextBox2.Value Then
    ......
    .......
    Else
    ........

    End If

    but I am getting strange results with the above code
    Is their a better solution to this.

    Regards

    Subs



  2. #2
    K Dales
    Guest

    RE: Textboxes

    It would help to see what the strange results are, but I have an educated
    guess. Do the textboxes contain numbers you want to compare? Textbox values
    are strings; an alpha comparison on strings gives different results than a
    numeric comparison - to see what I mean try this in the immediate pane:
    ? "10" > "2"
    Should show the answer is "False" - alphabetically, the "1" in "10" comes
    before "2".
    Do it this way:
    If Val(Textbox3.Value) > Val(Textbox2.Value) Then ...
    This converts the text to numeric values for the comparison
    --
    - K Dales


    "Subs" wrote:

    > Hi All
    >
    > I am trying to evaluate two textboxes
    >
    > If TextBox3.Value > TextBox2.Value Then
    > ......
    > .......
    > Else
    > ........
    >
    > End If
    >
    > but I am getting strange results with the above code
    > Is their a better solution to this.
    >
    > Regards
    >
    > Subs
    >
    >
    >


  3. #3
    xxpeter
    Guest

    Re: Textboxes

    Hi,

    In the same way of thinking you can also convert the results to a
    certain type and compare then :

    If CInt(Textbox3.Value) > CInt(Textbox2.Value) Then ...
    This converts the text to Integer values for the comparison

    Warning : it's also good to check those values BEFORE you make the
    comparison.
    You can make the check with IsNumeric

    Peter


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1