+ Reply to Thread
Results 1 to 3 of 3

declaring public variables

  1. #1
    Loane Sharp
    Guest

    declaring public variables

    Hi there

    The following is most bizarre!

    In my VBA project I've declared several public variables as normal (ahead of
    all procedures) ... Public ctrNegInv, ctrPosInv As Integer, etc.

    I set the values in one procedure and then execute a second procedure but,
    when the variable is encountered in the second procedure, it appears to be
    empty and I get a "Subscript out of range" error.

    For instance, if I hover the cursor over the variable in the variable
    declarations section, it says ctrNegInv = Empty, whereas if I hover the
    cursor in the procedure where I set it's value it says ctrNegInv=0, and
    further if I hover the cursover in the subsidiary or later procedures I get
    ctrNegInv = Empty.

    Can I be going mad?

    Best regards
    Loane




  2. #2
    Bob Phillips
    Guest

    Re: declaring public variables

    Hi Loane,

    You aren't declaring the same variable in one of those procedures by any
    chance?

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Loane Sharp" <[email protected]> wrote in message
    news:[email protected]...
    > Hi there
    >
    > The following is most bizarre!
    >
    > In my VBA project I've declared several public variables as normal (ahead

    of
    > all procedures) ... Public ctrNegInv, ctrPosInv As Integer, etc.
    >
    > I set the values in one procedure and then execute a second procedure but,
    > when the variable is encountered in the second procedure, it appears to be
    > empty and I get a "Subscript out of range" error.
    >
    > For instance, if I hover the cursor over the variable in the variable
    > declarations section, it says ctrNegInv = Empty, whereas if I hover the
    > cursor in the procedure where I set it's value it says ctrNegInv=0, and
    > further if I hover the cursover in the subsidiary or later procedures I

    get
    > ctrNegInv = Empty.
    >
    > Can I be going mad?
    >
    > Best regards
    > Loane
    >
    >
    >




  3. #3
    Tom Ogilvy
    Guest

    Re: declaring public variables

    Is the variable declared in a standard module, the type you get with
    Insert=>Module and in the same project as the procedures that want to use
    it?

    --
    Regards,
    Tom Ogilvy


    "Loane Sharp" <[email protected]> wrote in message
    news:[email protected]...
    > Hi there
    >
    > The following is most bizarre!
    >
    > In my VBA project I've declared several public variables as normal (ahead

    of
    > all procedures) ... Public ctrNegInv, ctrPosInv As Integer, etc.
    >
    > I set the values in one procedure and then execute a second procedure but,
    > when the variable is encountered in the second procedure, it appears to be
    > empty and I get a "Subscript out of range" error.
    >
    > For instance, if I hover the cursor over the variable in the variable
    > declarations section, it says ctrNegInv = Empty, whereas if I hover the
    > cursor in the procedure where I set it's value it says ctrNegInv=0, and
    > further if I hover the cursover in the subsidiary or later procedures I

    get
    > ctrNegInv = Empty.
    >
    > Can I be going mad?
    >
    > Best regards
    > Loane
    >
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1