Results 1 to 6 of 6

Thread: [RESOLVED] how to say a variant "is nothing" or "is null"?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Posts
    255

    Resolved [RESOLVED] how to say a variant "is nothing" or "is null"?

    Dear all,

    I have the following declaration in the top of a form:

    Public my_global_Array As Variant


    then, in a function, I want to check if this my_global_Array has "content" or not. In case it does not have content (it is null or it is nothing), I will load some data from recordset to this array.

    But I dont know how to check if it is nothing. I have tried the following codes:

    If (my_global_Array = "") Or (my_global_Arrays Is Null) or (my_global_Array is nothing) Then
    call sub_load_rs
    End If

    It returns a fail message which says: "Object required."

    What is the code for an variant is nothing?

    Thanks

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: how to say a variant "is nothing" or "is null"?

    Assuming it would be an array you can try using the IsArray function.
    Code:
    Dim my_global_Array As Variant
    MsgBox IsArray(my_global_Array)
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602

    Re: how to say a variant "is nothing" or "is null"?

    In think you can use one of these to check:

    IsNull(my_global_Array)
    IsEmpty(my_global_Array)
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: how to say a variant "is nothing" or "is null"?

    The value Empty denotes a Variant variable that hasn't been initialized (assigned an initial value). A Variant containing Empty is 0 if it is used in a numeric context and a zero-length string ("") if it is used in a string context.

    Don't confuse Empty with Null. Null indicates that the Variant variable intentionally contains no valid data.
    Use IsEmpty(v)
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Posts
    255

    Re: how to say a variant "is nothing" or "is null"?

    thanks, isempty() is good.
    i tested it

  6. #6
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: [RESOLVED] how to say a variant "is nothing" or "is null"?

    Just for completeness, "Is Nothing" only works on objects, which is why you were getting the Object Required error message.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width