VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



TextBox accepts only numeric value,backspace and single decimal

by Dharam Bahadur Gharti (2 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 22nd March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

TextBox accepts only numeric value,backspace and single decimal

Rate TextBox accepts only numeric value,backspace and single decimal



            Text1.Text = " "
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
            If KeyAscii = vbKeyBack Then Exit Sub
            If KeyAscii = Asc(".") And InStr(1, Text1.Text, ".") = 0 Then
               KeyAscii = Asc(".")
               Exit Sub
            End If
          If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0
            
End Sub


Download this snippet    Add to My Saved Code

TextBox accepts only numeric value,backspace and single decimal Comments

No comments have been posted about TextBox accepts only numeric value,backspace and single decimal. Why not be the first to post a comment about TextBox accepts only numeric value,backspace and single decimal.

Post your comment

Subject:
Message:
0/1000 characters