如何在保存时分离命令

时间:2016-05-10 13:53:07

标签: vb.net

此代码正常工作,但现在我想要如果所有文本框(Tbxs)都已填充但是图片框(Pbx1)中没有包含要显示的Msgbox图像"现在加载照片"

If Tbx1.Text = "" Or Tbx2.Text = "" Or Tbx3.Text = "" Or Tbx4.Text = ""  Or Pbx1.Image Is Nothing Then
        MsgBox("Kindly Fill the Blank Cells", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
        Exit Sub
    End If 

我将如何做到这一点?

1 个答案:

答案 0 :(得分:0)

这是你的意思吗?

    If (Tbx1.Text = "" Or Tbx2.Text = "" Or Tbx3.Text = "" Or Tbx4.Text = "") And Pbx1.Image Is Nothing Then
        MsgBox("Kindly Fill the Blank Cells", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
        Exit Sub
    ElseIf CheckFilled({Tbx1, Tbx2, Tbx3, Tbx4}) And Pbx1.Image Is Nothing Then
        MsgBox("Now Load Photo", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)

    End If

Private Function CheckFilled(Tb As TextBox()) As Boolean
    Dim retVal As Boolean = True

    For Each t As TextBox In Tb
        If t.Text.Length <= 0 Then retVal = False
    Next

    Return retVal
End Function