我有这个简单的事件宏,由于某种原因抛出了我
此行需要对象
@IBAction func OkBtnWasPressed(_ sender: Any) {
// update text to selected value
if selectedType == nil {
typeTextField.text = pickerData[defaultRow]
} else {
typeTextField.text = selectedType
}
animateOut()
}
上的错误。知道可能导致这种情况的原因吗?
If Not AppDate Is Nothing Then
任何建议都将不胜感激。谢谢!
答案 0 :(得分:7)
Is
运算符使用对象而不是值。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim x As Variant
Dim y As New Collection
Dim z As Object
x = Target.Value
If IsEmpty(x) Then
MsgBox "may be use this."
End If
MsgBox TypeName(x)
If y Is Nothing Then
MsgBox "Works"
End If
If z Is Nothing Then
MsgBox "Works"
End If
If x Is Nothing Then '/This won't work
End If
End Sub
答案 1 :(得分:4)