Results 1 to 4 of 4

Thread: validating data

  1. #1
    Guest

    Question

    Is there a function that validates that the user has typed letters and not numbers? I have an input box and i need that the user types only numbers.

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Location
    Trondheim, Norway
    Posts
    65
    This code will help you if it's just a plain text box.

    Private Sub Text1_KeyPress(KeyAscii As Integer)

    If KeyAscii < 48 Or KeyAscii > 57 Then
    KeyAscii = 0
    End If

    End Sub

    Don't know how to get it right if it's an InputBox function you are talking about here...

    D

  3. #3
    Lively Member
    Join Date
    Aug 2000
    Location
    Trondheim, Norway
    Posts
    65
    If KeyAscii > 48 And KeyAscii < 57 Then
    KeyAscii = 0
    End If

    Inverted...

    D

  4. #4
    New Member
    Join Date
    Oct 2000
    Posts
    9
    If your using a text box then then checking the keyascii will work fine. If your using an inputbox, then you will need to do something like this

    Code:
    Dim strNumber as string
    do until IsNumeric(strNumber) = True
        strNumber = InputBox("Enter A Number")
        'To Display A Message
        If Not IsNumeric(strNumber) Then msgbox("That is not a number")
    loop
    'Do Something with the number
    Terry

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