![]() |
Calling a sub
Someone else posted this really useful code for validating textboxes:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Select Case KeyAscii Case 48 To 57 'numbers Case Else 'Discard anything else Beep KeyAscii = 0 End Select End Sub Only problem is that I have numerous textboxes to check and I've currently listed this for every box. How do I package this so that for each textbox I can use something similar to: Private Sub txtBankNum4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Call NumCheck End Sub |
Calling a sub
Try somethin like this...
Private Sub txtBankNum4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Call NumberValid(KeyAscii) End Sub Private Sub NumCheck(ByRef KeyAscii As MSForms.ReturnInteger) Select Case KeyAscii Case 48 To 57 'numbers Case Else 'Discard anything else Beep KeyAscii = 0 End Select End Sub -- HTH... Jim Thomlinson "BOBODD" wrote: Someone else posted this really useful code for validating textboxes: Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Select Case KeyAscii Case 48 To 57 'numbers Case Else 'Discard anything else Beep KeyAscii = 0 End Select End Sub Only problem is that I have numerous textboxes to check and I've currently listed this for every box. How do I package this so that for each textbox I can use something similar to: Private Sub txtBankNum4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Call NumCheck End Sub |
All times are GMT +1. The time now is 01:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com