【问题标题】:vba, outlook, Userform if comebox & text fieldsvba、outlook、用户窗体如果组合框和文本字段
【发布时间】:2017-10-25 01:10:26
【问题描述】:

我有一个带有 1 个组合框字段和几个文本字段的用户表单。 组合框 1 = 应用类型(7 个不同的结果) 姓名、姓氏、城镇、邮政编码等文本字段。

按确定按钮后,如果缺少必填字段,我想提示用户。

1 选择的必填字段是字段 1、字段 2 和字段 3 对于选择 2 仅提交 1 和 2 对于 3 仅字段 6 等等

奇怪的是,如果我选择了我没有在这个 sub 中定义的东西,我选择了 4 或 5 值,我仍然会收到消息。 我错过了什么?

Private Sub CommandButton1_Click()

If UserForm2.ComboBox1T.Value = "1.New Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Or TextBox3.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")


Exit Sub
End If


If UserForm2.ComboBox1T.Value = "2.Old Application" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")

Exit Sub
End If

If UserForm2.ComboBox1T.Value = "3.Somethingelse" _
And TextBox1.Text = "" _
Or TextBox2.Text = "" _
Then
MsgBox ("Fill in all mandatory Fields")


Exit Sub
End If

【问题讨论】:

  • 啊,我知道你错过了什么。想念this,感谢那些抽出宝贵时间回答您问题的人。
  • 我的错误,全部排序。我刚开始使用 stackoverflow,并不确定一切是如何工作的。

标签: vba outlook userform


【解决方案1】:

找到解决方案。

 With Me 
   Select Case .ComboBox1T 
  Case "1.New Application" 
    If .TB1 = "" Or .TB2 = "" Or .TB3 = ""  Then MsgBox ("Something")

  Case "2.old Application" 
    If .TB1 = "" Or .TB2 = "" Then MsgBox ("Something")

Case "3.Other Application" 
    If ........

Case "4." 
Case "5." 
Case "6." 
Case "7." 


End Select 
End With 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    • 2020-11-15
    • 2017-12-23
    • 1970-01-01
    • 2020-08-12
    • 1970-01-01
    • 2022-07-02
    相关资源
    最近更新 更多