|
-
May 23rd, 2000, 05:43 PM
#1
Thread Starter
Junior Member
hi
what is the initial value of string when it's declared it as
dim sample as string.
what is vbnull string ??? how it's differenrt from length of ( len function ) string is zero.
pl. explain in detail what is empty string , what is null string , what zero length string ????
pl. give me a reply....
sanju
-
May 23rd, 2000, 06:18 PM
#2
Hyperactive Member
Empty Null != Zero
Hello Silla
Here are some of the answers. These are found in the MSDN if you search for Null, Empty, Zero.
Hope that it will help you.
Null
A value indicating that a variable contains no valid data. Null is the result of an explicit assignment of Null to a variable or any operation between expressions that contain Null.
Empty
Indicates that no beginning value has been assigned to a Variant variable. An Empty variable is represented as 0 in a numeric context or a zero-length string ("") in a string context.
zero-length string
A string containing no characters (""). The Len function of a zero-length string returns 0.
The Empty Value
Sometimes you need to know if a value has ever been assigned to a created variable. A Variant variable has the Empty value before it is assigned a value. The Empty value is a special value different from 0, a zero-length string (""), or the Null value. You can test for the Empty value with the IsEmpty function:
If IsEmpty(Z) Then Z = 0
When a Variant contains the Empty value, you can use it in expressions; it is treated as either 0 or a zero-length string, depending on the expression.
The Empty value disappears as soon as any value (including 0, a zero-length string, or Null) is assigned to a Variant variable. You can set a Variant variable back to Empty by assigning the keyword Empty to the Variant.
The Null Value
The Variant data type can contain another special value: Null. Null is commonly used in database applications to indicate unknown or missing data. Because of the way it is used in databases, Null has some unique characteristics:
Expressions involving Null always result in Null. Thus, Null is said to "propagate" through expressions; if any part of the expression evaluates to Null, the entire expression evaluates to Null.
Passing Null, a Variant containing Null, or an expression that evaluates to Null as an argument to most functions causes the function to return Null.
Null values propagate through intrinsic functions that return Variant data types.
You can also assign Null with the Null keyword:
Z = Null
You can use the IsNull function to test if a Variant variable contains Null:
If IsNull(X) And IsNull(Y) Then
Z = Null
Else
Z = 0
End If
If you assign Null to a variable of any type other than Variant, a trappable error occurs. Assigning Null to a Variant variable doesn't cause an error, and Null will propagate through expressions involving Variant variables (though Null does not propagate through certain functions). You can return Null from any Function procedure with a Variant return value.
Variables are not set to Null unless you explicitly assign Null to them, so if you don't use Null in your application, you don't have to write code that tests for and handles it.
For More Information For information on how to use Null in expressions, see "Null" in the Language Reference.
Onerrorgoto
Dont be to optimistic, the light at the end of the tunnel might be a train
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|