How to protect text box for writing of number and characters VB6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jolace
    New Member
    • Apr 2007
    • 16

    How to protect text box for writing of number and characters VB6

    How i can protext text box which i use for showing const of writing numbers and leters t.e char
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by Jolace
    How i can protext text box which i use for showing const of writing numbers and leters t.e char
    Tress keyascii value and allow or disallow it

    Comment

    • Jolace
      New Member
      • Apr 2007
      • 16

      #3
      Originally posted by vijaydiwakar
      Tress keyascii value and allow or disallow it
      can you help me with the code? it txt3.text when i submit results

      Comment

      • vijaydiwakar
        Contributor
        • Feb 2007
        • 579

        #4
        Originally posted by Jolace
        can you help me with the code? it txt3.text when i submit results
        this code may help u
        Code:
        Private Sub Text1_KeyPress(KeyAscii As Integer)
            KeyAscii = validateonlunum(KeyAscii)
        End Sub
        Private Function validateonlunum(ByRef keyas As Integer)
        Dim Validstr$
        sValidstr = "0123456789"
            If InStr(sValidstr, Chr(keyas)) = 0 Then validateonlunum = 0 Else validateonlunum = keyas
        End Function

        Comment

        • Jolace
          New Member
          • Apr 2007
          • 16

          #5
          [QUOTE=vijaydiwa kar]this code may help u
          [CODE]
          Private Sub Text1_KeyPress( KeyAscii As Integer)
          KeyAscii = validateonlunum (KeyAscii)
          End Sub
          When i write:

          Private Function validateonlunum (ByRef keyas As Integer)
          Dim Validstr$
          sValidstr = "0123456789 "
          If InStr(sValidstr , Chr(keyas)) = 0 Then validateonlunum = 0 Else validateonlunum = keyas
          End Function

          Show me message: only comments may be appear after end sub end fuction.... well i can ask you for more help?

          Comment

          • vijaydiwakar
            Contributor
            • Feb 2007
            • 579

            #6
            see its a perfect sol try it
            Code:
             
            Private Sub Text1_KeyPress(KeyAscii As Integer)
                KeyAscii = validateonlunum(KeyAscii)
            End Sub
            Private Function validateonlunum(ByRef keyas As Integer)
            Dim sValidstr$
            sValidstr = "0123456789"
                If InStr(sValidstr, Chr(keyas)) = 0 Then validateonlunum = 0 Else validateonlunum = keyas
            End Function

            Comment

            Working...