Results 1 to 3 of 3

Thread: Protecting data types entered in text boxes.

  1. #1

    Thread Starter
    Hyperactive Member nickwrs's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta, Ga
    Posts
    398

    Lightbulb

    I have a program where I ask for certain information that needs to be a #.

    But I have some idiots who use it who seem to want to put periods or commas or other stupid things and it causes a run time error I know I can capture the run time error, but is there a way to make sure that what the person enters in a text box is simply a #?

    and then I would want to prompt them to only enter a #.


    Thanks.

    Nick.

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Location
    Ontario, Canada
    Posts
    79
    What about putting the following code in the Change() event (assuming the TextBox is called sleName):

    Code:
     If IsNumeric(sleName.Text) <> True Then
            MsgBox ("Error")
            sleName.Text = Left(sleName.Text, Len(sleName.Text) - 1)
            sleName.SelStart = Len(sleName.Text)
    End If

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    the maskedit box control was built for such cases.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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