Was ist der Unterschied zwischen "Null" und "Nichts" in VB6?

Ich habe ein recordset, wie diese:

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

Fand ich heraus, dass in VB6 habe ich selten verwenden Sie "Null" (ich habe es für die Bewertung der leere schema-Namen), aber ich benutze "Nichts" für Sachen wie Bilder, adodb.verbindungen oder recordsets. Für strings habe ich vbNullString. Ich habe gelesen es ist ein Zeiger auf einen null-string.

Ist "Null" wie eine "unbekannte variable "Wert" und "Nichts" eine echte null-Wert?

InformationsquelleAutor Broken_Window | 2014-04-24

Schreibe einen Kommentar