Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Oct 2008
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have a number of textboxes on a user form. I want to restrict the input to this boxes to numbers from 0 to 1 (ie 0.12) or to a string of "N/A". What procedure call should I use for such a textbox: Click, Change, KeyDown? and why?

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    [quote name='CFDguru' post='765233' date='13-Mar-2009 13:31']I have a number of textboxes on a user form. I want to restrict the input to this boxes to numbers from 0 to 1 (ie 0.12) or to a string of "N/A". What procedure call should I use for such a textbox: Click, Change, KeyDown? and why?[/quote]


    You could use the Exit event to validate the contents. If they don't match, pop up a message and set the Cancel argument to True.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    2 Star Lounger
    Join Date
    Oct 2008
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='rory' post='765234' date='13-Mar-2009 09:41']You could use the Exit event to validate the contents. If they don't match, pop up a message and set the Cancel argument to True.[/quote]
    Can you give me an example?

  4. #4
    2 Star Lounger
    Join Date
    Oct 2008
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have attached an example of what I currently have. The problem I have is that when I click on the N/A checkbox I get a message that I setup in the textbox event. How can I fix this so it will work properly?
    Attached Files Attached Files

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I'd add the following lines at the beginning of the Exit_txtA event procedure:

    If txtA.Value = "" Then
    Exit Sub
    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
  •