ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   User Form in VB = TextBox (https://www.excelbanter.com/excel-discussion-misc-queries/39709-user-form-vbulletin-%3D-textbox.html)

Kel

User Form in VB = TextBox
 
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

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



Kel wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 04:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com