User Form in VB = TextBox

K

Kel

Hi again

I crated a User Form in VB and added a TextBox and i want the user to be
able to enter 'Numbers only' not characters can anyone provide info please,
if the user is trying to input other then numbers give no respond.

thnx in advance
 
D

Dave Peterson

Something like:

Option Explicit
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

Select Case KeyAscii
Case Asc("0") To Asc("9")
'do nothing
Case Else
Beep
KeyAscii = 0
End Select

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top