如何通过循环语句确定窗体上文本框是否为空记录
如何通过循环语句确定窗体上文本框是否为空记录
[解决办法]
- VB.NET code
For Each c As Control In Me.Controls If c.GetType() Is GetType(TextBox) Then If c.Text.Length = 0 Then 'If c.Text.Trim().Length = 0 Then MessageBox.Show(String.Format("文本框{0}值为空", c.Name)) End If End If Next
[解决办法]
private sub SetText(Ct as control)
For Each c As Control In Me.Controls
If c.GetType() Is GetType(TextBox) Then
If c.Text.Length = 0 Then 'If c.Text.Trim().Length = 0 Then
Console.WriteLine(String.Format("文本框{0}值为空", c.Name))
If c.HasChildren Then
SetText(c)
End If
End If
End If
Next
End sub
[解决办法]