vba,outlook,Userform if comebox&文本字段

时间:2017-05-24 15:25:03

标签: vba outlook userform

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

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

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

奇怪的是,如果我选择了我在这个子中没有定义的东西,我选择值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

1 个答案:

答案 0 :(得分:0)

找到解决方案。

public static void main(String[] args){
        Scanner a = new Scanner(System.in);
        int varOne = a.nextInt();
        int varTwo = a.nextInt();
        int sum = varOne + varTwo;
        System.out.println(sum);
        a.close();
}