Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

numerical textbox entry

how can you make a textbox so that you can only enter numbers?
0
cabananna
Asked:
cabananna
1 Solution
 
StateCommented:
Private Sub Text_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 And KeyAscii <> 8 Then KeyAscii = 0
End Sub
0
 
List244Commented:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then Exit Sub
If IsNumeric(Chr(KeyAscii)) = False Then KeyAscii = 0
End Sub

His also works, but this allows them to hit backspace incase they typed the wrong number and need to erase it
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now