View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Shawn Shawn is offline
external usenet poster
 
Posts: 271
Default limit textbox to blank or exactly 4 numberic digits

I added this below the message box:

MsgBox "This box must be blank or contain exactly 4 numbers!", vbOKOnly
If VBAOk Then
usfDemo.txtbxPhonePost.Text = ""
usfDemo.txtbxPhonePost.SetFocus
End If

However, the textbx doesn't clear or select?

--
Thanks
Shawn


"Shawn" wrote:

This works

Private Sub txtbxPhonePost_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If txtbxPhonePost.Value = "" Then
usfDemo.cmbxDOBMonth.SetFocus
Else
If IsNumeric(usfDemo.txtbxPhonePost.Text) = False Then
MsgBox "This box must be blank or contain exactly 4 numbers!",
vbOKOnly
Else
If Len(usfDemo.txtbxPhonePost.Text) < 4 Then
MsgBox "This box must be blank or contain exactly 4
numbers!", vbOKOnly
End If
End If
End If
End Sub

Is there a better way?
--
Thanks
Shawn