“与”的区别是什么;空";及;“什么都没有”;在VB6中?

“与”的区别是什么;空";及;“什么都没有”;在VB6中?,vb6,Vb6,我有这样一个记录集: 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

我有这样一个记录集:

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
Dim rs作为记录集
将rs设置为新记录集
'... 大量的编码。。。
如果错误号为0,那么“哎呀,出问题了!”!
如果rs.State ADSTATES关闭,则rs.关闭
设置rs=无
如果结束
'我想计算rs是否为Nothing或Null
如果rs什么都不是
“这不会抛出错误,而且效果很好:D
如果结束
如果rs为空,则
'这会引发“类型不兼容”错误
如果结束
如果rs=Null,则
'这会引发“类型不兼容”错误
如果结束
如果为空(rs),则
'从不在此处输入,isNull(rs)的计算结果为False
如果结束
我发现在VB6中,我很少使用“Null”(我用它来计算空记录集模式名),但我对图像、adodb.connections或记录集之类的东西使用“Nothing”。对于字符串,我有vbNullString。我读到它是一个指向空字符串的指针


“Null”是否与“未知变量值”类似,“Nothing”是否为真正的Null值?

Null是变量的特定子类型。它在变量类型之外不存在,创建它是为了允许变量对数据库空值进行建模

没有任何内容是对象变量的值。它本质上与空指针相同,即没有对象

以下内容引发错误,因为“Is”只能与对象变量一起使用:

if rs is Null then
' this throws an error of "types not compatible"
end if
以下内容引发错误,因为对象变量永远不能为Null:

if rs = Null then
' this throws an error of "types not compatible"
end if
以下计算结果为False,因为IsNull()接受一个变量参数

if isNull(rs) then
' never enters here, isNull(rs) evaluates to False
end if
这相当于:

VarType(rs) = vbNull

下表说明了如何使用VBScript关键字

  • 空的

    Empty关键字用于指示未初始化的变量值。这与Null不同

  • 假的

    False关键字的值等于0

  • 没什么

    VBScript中的Nothing关键字用于解除对象变量与任何实际对象的关联。使用Set语句不为对象变量赋值。例如:

多个对象变量可以引用同一个实际对象。当没有为对象变量赋值时,该变量不再引用任何实际对象。当多个对象变量引用同一个对象时,与变量所引用的对象关联的内存和系统资源只有在所有这些资源都被设置为Nothing后才会释放,无论是显式地使用set,还是在最后一个对象变量设置为Nothing后隐式地超出范围

  • 空的

    Null关键字用于指示变量不包含有效数据。这和空的不一样

  • 真的

    True关键字的值等于-1

您可以尝试以下操作:

a = "SELECT SBio.biosrno,YearlyCharges.adnum,Name,sName
FROM SBio RIGHT JOIN YearlyCharges ON SBio.biosrno=YearlyCharges.adnum
WHERE  (SBio.biosrno IS  NULL );"

还有另一个变量值
Empty
a = "SELECT SBio.biosrno,YearlyCharges.adnum,Name,sName
FROM SBio RIGHT JOIN YearlyCharges ON SBio.biosrno=YearlyCharges.adnum
WHERE  (SBio.biosrno IS  NULL );"