【发布时间】:2016-10-25 00:11:28
【问题描述】:
我创建了一个带有复选框的名为“questionario”的表单,并制作了一个 IF 语句,如果所有复选框都是空白的,则发送一个 msgbox。但是当我运行宏时,引用的行中会出现错误(错误 438)。
Private Sub CommandButton1_Click()
Dim ind As Integer
Dim cont As MSForms.Control
ind = 0
If questionario.resp1.Value = True Then
Range("E8").Value = Range("E8").Value + 1
End If
If questionario.resp2.Value = True Then
Range("F8").Value = Range("F8").Value + 1
End If
If questionario.resp3.Value = True Then
Range("G8").Value = Range("G8").Value + 1
End If
For Each cont In questionario.Controls
If (TypeName(cont) = "CheckBox") And (cont.Value = True) Then
ind = ind + 1
End If
Next
If ind = 0 Then
MsgBox "mmm"
Else
questionario.Hide
Set questionario = Nothing
End If
End Sub
【问题讨论】:
-
你可以试试
If cont.TypeName = ...吗? -
我试过了,但我认为问题出在
And (cont.Value = True)部分