Changes

String Functions and Manipulation in VB6

1,779 bytes added, 22:46, 15 February 2008
/* Null, 0, and Empty Strings */
The following lines were added (+) and removed (-):
* '''Null''': Used for writing NULL in SQL standard, a NULL to the database, which will appear as a 0 in a numeric field.* '''Null''': Used for writing NULL, however, will appear as a 0 in a database numeric field after write. * '''Empty''': Also appears as a 0 in a database numeric field after write. * '''Nothing''':  === The Differences among Empty, Nothing, vbNull, vbNullChar, vbNullString and the Zero-Length String === quoted from somewhere:   '''""''': A zero-length string (commonly called an "empty string") is technically a zero-length BSTR that actually uses six bytes of memory. In general, you should use the constant vbNullString instead, particularly when calling external DLL procedures. '''Empty''': A variant of VarType 0 (vbEmpty) that has not yet been initialized. Test whether it is "nil" using the IsEmpty function. '''Nothing''': Destroys an object reference using the Set statement. Test whether it is "nil" using the Is operator: If obj Is Nothing Then... '''Null''': A variant of VarType 1 (vbNull) that means "no valid data" and generally indicates a database field with no value. Don't confuse this with a C NULL, which indicates zero. Test whether it is "nil" using the IsNull function. '''vbNullChar''': A character having a value of zero. It is commonly used for adding a C NULL to a string or for filling a fixed-length string with zeroes: Path = String(255, vbNullChar) '''vbNullString''': A string having a value of zero, such as a C NULL, that takes no memory. Use this string for calling external procedures looking for a null pointer to a string. To distinguish between vbNullString and "", use the VBA StrPtr function: StrPtr(vbNullString) is zero, while StrPtr("") is a nonzero memory address. [Note: the StrPtr() function may not be a part of the VBA members shown in the Object Browser so it will not AutoComplete. Enter the following line in the Immediate Window to determine if this function is available: ?StrPtr(vbNullString). This should return 0 immediately.] 
Bureaucrat, administrator
16,192
edits