validating Text box input

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ruvini218
    New Member
    • Feb 2008
    • 1

    validating Text box input

    How can i make a text box to accept only numeric values?
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    Use code such as:
    [codetext]
    if integer.parse(t extbox1.text) = true then
    'do what you want
    end if
    [/code]

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      try handle the keyascii in the keypress event of the textbox.

      accept the required values and discard the rest.

      Comment

      • werks
        New Member
        • Dec 2007
        • 218

        #4
        try this

        [CODE=vb 6]
        Public Function OnlyNum(KeyAsci i As Integer)
        Select Case KeyAscii
        Case 48 To 57 '0-9
        Case 13 'carriage return
        Case 8 'backspace
        Case Else
        KeyAscii = 0 'null
        End Select
        End Function
        [/CODE]

        --
        Kenneth
        "Better Than Yesterday"

        Comment

        Working...