Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Character limit in textbox | Excel Worksheet Functions | |||
Limit Number in cell to 5 Digits | Excel Discussion (Misc queries) | |||
Limit the amount of digits displayed in a field in Excel or Access | Excel Discussion (Misc queries) | |||
Limit Digits entered into a cell | Excel Discussion (Misc queries) | |||
in excel, how to limit digits of negative hexadecimal numbers? | Excel Discussion (Misc queries) |