我有这样的记录集:
Dim rs as Recordset
Set rs as New Recordset
'... a lot of coding ...
if Err.Number <> 0 Then ' oops, something gone wrong!
If rs.State <> adStateClosed Then rs.Close
Set rs = Nothing
end if
' I want to evaluate if rs is Nothing, or Null
if rs is Nothing then
' this doesn't throw errors, and works well :D
end if
if rs is Null then
' this throws an error of "types not compatible"
end if
if rs = Null then
' this throws an error of "types not compatible"
end if
if isNull(rs) then
' never enters here, isNull(rs) evaluates to False
end if
我发现在VB6中很少使用"Null"(我只用它来评估空记录集模式名称),但是对于像图像、adodb.connections或recordsets之类的东西,我使用"Nothing"。对于字符串,我有vbNullString。我读到它是指向空字符串的指针。
"Null"是否像"未知变量值",而"Nothing"是真正的null值?
Empty
。 - Bob77