Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If then MsgBox
On Userform1, I have TextBox1. I am trying to acheive the following... If
when the user clicks CommandButton1 and Textbox1 equals "" or "Enter Stat Name here", then I would like a message box to popup telling the user "INVALID DATA". If when the user clicks CommandButton1 and Textbox1 does not equal "" or "Enter Stat Name here", then I would like the code to continue to the next part of the code which would be the message box saying "Are you sure?" Right now I am getting errors in the first messagebox. Below is what I have so far? Private Sub CommandButton1_Click() If TextBox1.Value = "" Or "Enter Stat Name here" Then MsgBox("Invalid Data", vbOKOnly) = vbOKOnly Else End If If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub End If End Sub Thanx Todd Huttenstine |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If then MsgBox
One way:
Private Sub CommandButton1_Click() With TextBox1 If .Value = "" Or .Value = "Enter Stat Name here" MsgBox("Invalid Data", vbOKOnly) Exit Sub End If End With If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub 'vbYes, so do something... End Sub In article , "Todd Huttenstine" wrote: On Userform1, I have TextBox1. I am trying to acheive the following... If when the user clicks CommandButton1 and Textbox1 equals "" or "Enter Stat Name here", then I would like a message box to popup telling the user "INVALID DATA". If when the user clicks CommandButton1 and Textbox1 does not equal "" or "Enter Stat Name here", then I would like the code to continue to the next part of the code which would be the message box saying "Are you sure?" Right now I am getting errors in the first messagebox. Below is what I have so far? Private Sub CommandButton1_Click() If TextBox1.Value = "" Or "Enter Stat Name here" Then MsgBox("Invalid Data", vbOKOnly) = vbOKOnly Else End If If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub End If End Sub Thanx Todd Huttenstine |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
If then MsgBox
Thanx, that worked.
Todd "J.E. McGimpsey" wrote in message ... One way: Private Sub CommandButton1_Click() With TextBox1 If .Value = "" Or .Value = "Enter Stat Name here" MsgBox("Invalid Data", vbOKOnly) Exit Sub End If End With If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub 'vbYes, so do something... End Sub In article , "Todd Huttenstine" wrote: On Userform1, I have TextBox1. I am trying to acheive the following... If when the user clicks CommandButton1 and Textbox1 equals "" or "Enter Stat Name here", then I would like a message box to popup telling the user "INVALID DATA". If when the user clicks CommandButton1 and Textbox1 does not equal "" or "Enter Stat Name here", then I would like the code to continue to the next part of the code which would be the message box saying "Are you sure?" Right now I am getting errors in the first messagebox. Below is what I have so far? Private Sub CommandButton1_Click() If TextBox1.Value = "" Or "Enter Stat Name here" Then MsgBox("Invalid Data", vbOKOnly) = vbOKOnly Else End If If MsgBox("Are you sure?", vbYesNo) = vbNo Then Exit Sub End If End Sub Thanx Todd Huttenstine |