Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is Nothing, Is Null, etc. in VB6

993 views
Skip to first unread message

K

unread,
Sep 25, 2001, 5:19:06 PM9/25/01
to
In VB6.0
How do I check different types to see if they have been
set.
Say I have a method called foo with the following
arguments:
….foo(arg1 As String, arg2 As Collection, arg3 As MyObject)

and within this method I want to check and see which one
of these arguments have been set by the client of the
method and which ones have not.

Do I use IsNothing for the Collection, IsNull for the
MyObject, and IsEmpty for the primitive String ?

Thanks.

Bob Butler

unread,
Sep 25, 2001, 6:26:33 PM9/25/01
to

"K" <kha...@yahoo.com> wrote in message
news:389601c14607$b5a02010$19ef2ecf@tkmsftngxa01...

You can test the collection and the object for Nothing as in "If arg2 Is
Nothing Then" but the only thing you can check on the string would be "If
Len(arg1)=0 Then" since a string can not be Empty, Nothing or Null. If you
want to be able to check for arguments not being passed at all you must make
the all Optional and type them as Variants and then you can use the
IsMissing() function to see what was actually passed by the client. You
then also have to check the actual type since they can pass anything in to a
Variant argument.

Robin Shen

unread,
Sep 25, 2001, 10:33:18 PM9/25/01
to
I don't think there are IsNothing function in VB. Usually we can use the
following functions:

IsNull to verify whether or not the one expression contains NULL.
IsObject to verify whether or not one expression is the vbObject type.
IsEmpty to verify whether or not one expression has been initialized.

You can select according to your own situation. Besides, you can also
consider using other possible ways for example check the length or the
string variable, the count proper of collection and etc.

Hope this helps,

Robin

0 new messages