View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default VBA data validation

Use code like the following:

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(Me.TextBox1.Text) = 6 Then
KeyAscii = 0
Else
Select Case KeyAscii
Case Asc("0") To Asc("9")
' OK
Case Else
KeyAscii = 0
End Select
End If

End Sub

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]



On Sat, 8 May 2010 01:22:24 -0700 (PDT), KK wrote:

Hi all,
I have created a textbox input on a userform. I would like to input
the postal code here and would like to dala validate it for a 6
numeric input. Is ther a way to do this