检查蒙面文本框

时间:2013-01-10 14:10:30

标签: vb.net maskedtextbox

我的表单中有五个蒙面文本框。有日期格式的两个被掩没的正文框,两与金钱和一个与电话号码。我使用下面给出的代码来检查这些框是否为空。

    Dim mtxt As Control
    Dim flagmtxt As Boolean
    flagmtxt = False
    For Each mtxt In EMPGBDATA.Controls
        If TypeOf mtxt Is MaskedTextBox Then
            If mtxt.Text = "" Then
                mtxt.BackColor = Color.Red
                flagmtxt = True
            End If
        End If
    Next

    If flagmtxt Then
        MessageBox.Show("Give Compleate Data!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    End If

我想避免检查带薪资格式的蒙面文本框。有没有机会??

1 个答案:

答案 0 :(得分:0)

flagmtxt = False
    For Each mtxt In EMPGBDATA.Controls
        If TypeOf mtxt Is MaskedTextBox Then
            If mtxt.Text = "" And mtxt.Name <> "MTXTPFESI" Then
                flagmtxt = True
            Else
                flagmtxt = False
            End If
        End If
    Next