首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

怎么通过循环语句确定窗体下文本框是否为空记录

2012-08-07 
如何通过循环语句确定窗体上文本框是否为空记录如何通过循环语句确定窗体上文本框是否为空记录[解决办法]V

如何通过循环语句确定窗体上文本框是否为空记录
如何通过循环语句确定窗体上文本框是否为空记录

[解决办法]

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
[解决办法]
探讨

如果包括文本框、组合框一起检查怎么办?如果有个别文本框允许这空,只检查其他不允许为空的文本框怎么办?

热点排行