如何检查vb.net中的空可见Maskedtextboxes?

问题描述:

我有大约50个Maskedtextboxes,只有少数可见。我需要的是只检查可见的,如果他们是空的。如何检查vb.net中的空可见Maskedtextboxes?

我用这个代码来检查所有Maskedtextboxes:

Dim empty = TabLABOR.Controls.OfType(Of MaskedTextBox)().Where(Function(txt) txt.Text.Length = 0) 
    If empty.Any Then 
     MessageBox.Show(String.Format("Please fill all fields", 
         String.Join(",", empty.Select(Function(txt) txt.Name)))) 
    Else 
     TabControlBlockD.SelectTab(TabMATERIALS) 
    End If 

End Sub 

你应该使用每个像下面

dim myfrm as MyCurrentForm() 

然后

for Each item As System.Windows.Forms.Control In myfrm.Controls 
     If item.GetType Is GetType(System.Windows.Forms.MaskedTexbox) Then 
      For Each mboxes As MaskedTexbox In item.Controls 
       If MaskedTexbox.text = "" AND maskedTextbox.visible = true Then 
        //Make deltu king of the world 
       End If 
      Next 
     End If 
    Next 

这应该工作。

编辑:

+0

谢谢,感谢你。但这并不是我想要的,我想要的只是检查可见的。 –

+0

哦。放在if语句中,条件是它应该是可见的。我相信这是用maskedtextbox.visible = true完成的 – deltu100