Re: VB6 and global variables

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: YYZ (notapplicable)
Date: 04/12/04


Date: Mon, 12 Apr 2004 15:18:43 -0500


<Don@home.com> wrote in message
news:shtl70p39j07a8qu4p02c4qu63ngo6lng9@4ax.com...
> On Mon, 12 Apr 2004 12:56:05 -0700, "Pete"
<anonymous@discussions.microsoft.com>
> wrote:
>
> >Hi All,
> >
> >Let me start by saying I know it is a bad programming practice.....

Yeah, it makes me shiver. Are you sure you need to do this? I can understadn
coding yourself into a corner, or inheriting a project that has already put you
there, but are you sure you can't do a global replace on one of them? Just a
suggestion.

> >If you have a GLOBAL variable (in a bas module) and you have a form and
inside of that form you have a variable that uses the same name as the GLOBAL,
how do you access the GLOBAL and not the routines version of the variable?
>
> For what ever its worth these varible names would be ambiguous...
> Change one...

Nope. Assuming 2 variables called sMyGlobal, VB would know exactly which one it
needed (if not what you really intended <g>). If you referred to sMyGlobal in
the form, it would find the pointer to the forms variable sMyGlobal. Anywhere
else, if you referred to sMyGlobal, then it would find the pointer to the
variable in the module.

If you want to specify try this (from the form):
Debug.Print Me.sMyGlobal, Module1.sMyGlobal

Just qualify which variable you want by specifying the module name (a form is a
module, too, if I'm not mistaken)

Matt



Relevant Pages

  • Re: Malcolms new book - Chapter 1 review
    ... user of the library function could decide on some suitable upper ... pointer to the next input line. ... attempt to allocate an arbitrarily large amount of memory. ... lets you specify a limit. ...
    (comp.lang.c)
  • Re: Problem opening VTAM-ACB
    ... I guess you must have been coding up TSO and a network solicitor to get you ... know that this is required if you specify the LU name of the 3270 secondary ... customisation of your VTAM. ... Checking on all your operands, this analysis of your use of the ...
    (bit.listserv.ibm-main)
  • Re: Malcolms new book - Chapter 1 review
    ... user of the library function could decide on some suitable upper ... pointer to the next input line. ... attempt to allocate an arbitrarily large amount of memory. ... lets you specify a limit. ...
    (comp.lang.c)
  • Re: HardBound and SoftBound
    ... technologies such as HardBound and SoftBound enable, in their tightest checking modes, for programming languages such as C and C++. ... (This somewhat diffident phraseology is intended to emphasize that technologies such as HardBound and SoftBound do not specify the programming language semantics; they just implement a semantics that the researchers believe is either compatible with the official semantics, or compatible with what the vast majority of users expect. ... In general, pointer extents are associated with pointer expressions, as well as with pointer variables and constants and parameters. ...
    (comp.arch)
  • Type Lib editor from Curland
    ... Still looking into making a Windows TypeLib and it looks the simplest way is to use the Type Library editor from ... Specify a handle opened by the WTSOpenServer function, or specify WTS_CURRENT_SERVER_HANDLE to indicate the terminal server on which your application is running. ... Pointer to a variable that receives a pointer to an array of WTS_PROCESS_INFO structures. ... Pointer to a variable that receives the number of WTS_PROCESS_INFO structures returned in the ppProcessInfo buffer. ...
    (microsoft.public.vb.general.discussion)