vbBack is string value
try Asc(vbBack)
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418
Solved Threads: 148
Skill Endorsements: 13
There are 2 ways to do this -
When your textbox looses focus, trap the error...
If Not IsNumeric(Text1.Text) Then
MsgBox "Numeric input only!", vbCritical, "Invalid Input"
Text1.Text = ""
End If
OR, you can just delete the letter that was typed so it only accepts numbers...
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Text1.Text) Then
SendKeys {Backspace}
End If
End Sub
''Note, you HAVE to reference Microsoft Scripting Library in your project...
''This will delete any letters or symbols except for numeric values. The ".," is allowed...
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20
Question Answered as of 2 Months Ago by
rishif2,
AndreRet
and
TnTinMN Only a pleasure. Happy coding...
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20