【发布时间】:2018-10-07 08:10:29
【问题描述】:
我有一个带有多个文本框的用户表单。如果 TextBox2 和/或 TextBox3 中有内容,但 TextBox1 中没有内容,我希望出现一个消息框。如果发生这种情况用户无法继续,我也希望这样做。
这是我当前的代码:
Private Sub SubmitCommandButtom_Click()
If Len(TextBox1) = "" And Len(TextBox2) > 0 Or Len(TextBox3) > 0 Then
MsgBox "Unit Number must be entered to continue!"
End If
Sheets("Uneven Split Job Aid").Range("A2") = TextBox1.Value
Sheets("Uneven Split Job Aid").Range("B2") = TextBox2.Value
Sheets("Uneven Split Job Aid").Range("C2") = TextBox3.Value
此代码目前仅在Textbox3中有值时才生成消息框,而TextBox1中没有,TextBox2中是否有任何内容都没有关系。我也希望它检查 TextBox2 的值。此外,当我在消息框上单击“确定”时,Sub 继续运行并将 TextBoxes 的值插入到工作表中。如果出现消息框,我想如果没有发生这种情况。
提前感谢您的帮助!
【问题讨论】: