Results 1 to 7 of 7

Thread: Only allow numbers and . in textbox

Threaded View

  1. #3
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Only allow numbers and . in textbox

    Exjames I alrady used that code in the code I uploaded in your calculator topic. But here I write it for you again:

    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
       Const allowed_chars As String = "0123456789."      'here add all the characters you want to allow in the textbox
       Dim char As String
       If KeyAscii = 8 Then Exit Sub          'this will allow the backspace key. if you don't want to allow the backspace key, they remove this line of code
       char = Chr(KeyAscii)
       If Instr(allowed_chars,char) = 0 Then KeyAscii = 0
    End Sub
    Last edited by lone_REBEL; Nov 21st, 2011 at 01:55 PM.
    If your problem is solved, then drag down the Thread Tools and mark your thread as Resolved.

    If I helped you solve your problem, inflate some air into my ego by rating my post and adding a comment too.

    For notorious issues (elaborate yourself) contact me via PM. I don't answer them in the forums EVER.

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