计算布尔运算符
Count Boolean Operators
我创建了一个需要填写某些字段的用户表单。他们的名字以 "R" 结尾,以便于识别。但是,我不知道如何计算布尔字段标记的空白字段的数量。如果 "True" 标志的数量大于 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
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!"
我创建了一个需要填写某些字段的用户表单。他们的名字以 "R" 结尾,以便于识别。但是,我不知道如何计算布尔字段标记的空白字段的数量。如果 "True" 标志的数量大于 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
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!"