我创建了一个用户表单,其中需要一些字段。他们的名字以" R"便于识别。但是,我无法弄清楚如何计算布尔字段标记的空白字段数。如果" True" flags大于0,我想显示错误消息。
For Each ctl In NewAsset.Controls
If Right(ctl.Name, 1) = "R" Then
If ctl.Value = "" Then
flag = True
End If
If ctl.Value <> "" Then
flag = False
End If
End If
Next
答案 0 :(得分:0)
Dim n As Long
For Each ctl In NewAsset.Controls
If Right(ctl.Name, 1) = "R" And ctl.Value = "" Then
n = n + 1
End If
Next
If n > 0 Then MsgBox n & " required fields are not filled!"