Consulting

Results 1 to 3 of 3

Thread: Assigning a null value to an Integer

  1. #1

    Assigning a null value to an Integer

    Hi,

    I am looking to assign a null value to an integer. Would this code do it?

    VarTypeThreshold4 = Null


    Cheers,

    Rob.

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    I do not believe you can. An Integer or Long are both initialized to zero. Also, I do not have a good explanation handy, but there is no reason to declare As Integer, just use Long.

  3. #3
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    When you Dim it, it is set to a value of 0 or Empty. If you set equal to vbNull, the value is 1. Review help for VarType to see why.

    The only way to get nothing is to not Dim it, do not use Option Explicit, and do not set it to any value. I find that poor practice myself.

Posting Permissions

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