+ Reply to Thread
Results 1 to 4 of 4

trouble comparing a value in a text box with a variable

  1. #1
    JasonK
    Guest

    trouble comparing a value in a text box with a variable

    i've got a userform with a text box.
    when the user inputs numerical data in the text box, i need the macro
    to compare that number with a number attached to a variable.

    both the text box number and the variable numbers match, but the macro
    is telling me they don't. i believe it's because the textbox is
    formatted as text and not as a value. how do i make the text in the
    box read as a number so that i can compare with a variable?

    the text box is named "checks" i tried:

    if checks.text = x then .......
    and
    if checks.value = x then.......

    but neither work.

    thanks in advance,
    jasonk

  2. #2

    Re: trouble comparing a value in a text box with a variable

    Try this

    if CInt(checks.text) = x then .......
    and
    if CInt(checks.value) = x then.......

    Note:
    CInt is you want to convert the value of the text box to INTEGER.


  3. #3
    Tom Ogilvy
    Guest

    Re: trouble comparing a value in a text box with a variable

    Just some added information
    You can also use

    clng to convert to long
    csng to convert to single
    cdbl to convert to double.

    Depends on what type of number you have.

    You can also look at the val function

    if Val(checks.text) = x then

    --
    Regards,
    Tom Ogilvy



    "[email protected]" wrote:

    > Try this
    >
    > if CInt(checks.text) = x then .......
    > and
    > if CInt(checks.value) = x then.......
    >
    > Note:
    > CInt is you want to convert the value of the text box to INTEGER.
    >
    >


  4. #4
    JasonK
    Guest

    Re: trouble comparing a value in a text box with a variable

    thanks arthur
    that worked perfectly.
    greatly appreciated.
    jasonk

    On 10 Apr 2006 01:57:30 -0700, [email protected] wrote:

    >Try this
    >
    >if CInt(checks.text) = x then .......
    >and
    >if CInt(checks.value) = x then.......
    >
    >Note:
    >CInt is you want to convert the value of the text box to INTEGER.



+ 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