![]() |
limit textbox to blank or exactly 4 numberic digits
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 |
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 |
limit textbox to blank or exactly 4 numberic digits
maybe
If VBOk Then Shawn wrote: 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 -- Dave Peterson |
limit textbox to blank or exactly 4 numberic digits
But since you're not giving the user a choice, why bother checking the response?
msgbox "This box must be blank or contain exactly 4 numbers!", vbOKOnly usfDemo.txtbxPhonePost.Text = "" usfDemo.txtbxPhonePost.SetFocus Shawn wrote: 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 -- Dave Peterson |
All times are GMT +1. The time now is 03:48 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com