Results 1 to 2 of 2

Thread: Compare Textbox values

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    8

    Question Compare Textbox values

    I have to textboxes that I want to compare so I can have a message box alert the user to incorrectly entered values.

    I can't seem to get the compare to work.

    textbox1 > textbox2

    This is what I have:

    Dim NTGvar, NTPvar As Variant

    NTGvar = textbox1
    NTPvar = textbox2

    If NTGvar > NTPvar Then
    MsgBox "Number of Gear teeth can not be less than teeth in Pinion", vbInformation + vbOKOnly, "Number of Teeth Error"

    Thanks for the assist
    David

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Compare Textbox values

    Convert string to numeric, Val function is not supported in VBScript, so you can use CInt or CDbl function

    Code:
    Dim NTGvar, NTPvar 
    
    NTGvar = CDbl(textbox1)
    NTPvar = CDbl(textbox2)
    
    If NTGvar > NTPvar Then
        MsgBox "Number of Gear teeth can not be less than teeth in Pinion", vbInformation + vbOKOnly, "Number of Teeth Error"
    End If



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