Re: Indirect referencing in VB6

From: Bonj (a_at_b.com)
Date: 04/28/04


Date: Wed, 28 Apr 2004 22:07:51 +0100

If there's any need for a user to be able to 'see into' an application, it
should be decided what data is going to be need to be seen and how much
informaion/in what format it needs to be presented. For instance, 'operating
variables' for business rules should be able to be seen maybe, but loop
counters, some tracking variables and flags, and intermediate calculations
perhaps shouldn't. Group together the variables that need to be exposed, and
if necessary wrap them with a class / put them into a collection or
whatever. You can then add whatever information is necessary and enumerate
them without needing code for each one (and possible future ones).

"Jonathan" <KingsKnight1@hotmail.com> wrote in message
news:ek91OsVLEHA.1388@TK2MSFTNGP09.phx.gbl...
> Wow, this generated a whole lot of conversation. Given that I'll try to
> explain where I'm coming from and where I want to go.
>
>
>
> I have a moderate sized application to which I want to add a small runtime
> diagnostics module. Really nothing more than a form with a text box and a
> list box that will display the value of public variables (listed in the
list
> box) at a given time. What I could have done (and did do) was set up a big
> SELECT statement so that when a variable name was selected from the list
> box, its value was displayed in the text box. Finding this very inelegant
I
> was trying to think of a more compact way to do it; somehow taking the
> literal variable names and somehow use them to point to the value. I was a
C
> programmer before I was a VB programmer so I must have been thinking of
> something I had done in C and thought it was VB. Oh well. Thanks for the
> contributions.
>
>
>
> Regards,
>
> Jonathan
>
>
>
> "Tony Proctor" <tony_proctor@aimtechnology_NOSPAM_.com> wrote in message
> news:OrAo7SVLEHA.1644@TK2MSFTNGP09.phx.gbl...
> > I understand why Rick is asking those questions. There is no direct
> > translation in VB, and so digging deeper to find what the OP really
wants
> to
> > achieve is the right way to go.
> >
> > I just wanted to point out that it may be that the OP was used to a
> > different language system, i.e. not a native VB user
> >
> > When mentioning 'other language systems' I was really think more about
> macro
> > processors than pointer-based languages. There's a strong analogy
between
> > the text indirection and macros calls of these systems with pointer
> > indirection and procedure calls in traditional languages.
> >
> > Tony Proctor
> >
> > "Bonj" <a@b.com> wrote in message
> > news:umnqq2ULEHA.1644@TK2MSFTNGP09.phx.gbl...
> > > It does use pointers though - what about when you pass a value byref,
> this
> > > is the VB equivalent of a C/C++ program passing a pointer. If VB wants
> to
> > > pass a long byref to an api, the C/C++ function has to be declared in
> the
> > > DLL with long* (long pointer).
> > > Thus, isn't it doing the same thing when it passes it to another of
its
> > own
> > > functions?
> > >
> > > "Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message
> > > news:OCY97ZTLEHA.2976@TK2MSFTNGP10.phx.gbl...
> > > > I know about pointers and 'C', but the whole language is structured
> for
> > > > their use (for example, access to Strings, which are not "strings"
in
> > > > 'C', rather they are arrays). It is my understanding that C++ sort
of
> > > > discourages their use and doesn't suffer for it. VB, like PASCAL
> > > > (another 'C' type derivative), doesn't use pointers at all and yet
> > > > coding in both is not hampered by this either. My question was
> basically
> > > > for the OP to cite a example (his code requirements) where this sort
> of
> > > > indirection (in VB) would be useful and could not easily be handled
> > > > using normal constructs.
> > > >
> > > > Rick - MVP
> > > >
> > > >
> > > > "Tony Proctor" <tony_proctor@aimtechnology_NOSPAM_.com> wrote in
> message
> > > > news:O20bEPTLEHA.2736@TK2MSFTNGP11.phx.gbl...
> > > > > It's a style supported, and encouraged, in some other language
> systems
> > > > > though Rick. In particular, pointer-based languages such as C do
> this
> > > > all
> > > > > the time. The only difference is that the linkage uses a binary
> > > > address
> > > > > rather than the symbolic name.
> > > > >
> > > > > Tony Proctor
> > > > >
> > > > > "Rick Rothstein" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in
message
> > > > > news:eVvMshSLEHA.3516@TK2MSFTNGP11.phx.gbl...
> > > > > > > Please tell me if there is a way to do this in VB6.
> > > > > > >
> > > > > > > I have a string variable. In this variable is the name of
> another
> > > > > > variable.
> > > > > > > Is there a way to access the contents of the 2nd variable
> through
> > > > the
> > > > > > first
> > > > > > > without using an IF or SELECT to test for all possibilities?
> > > > > > >
> > > > > >
> > > > > > > Dim strVar1 as String
> > > > > > >
> > > > > > > Dim strVar2 as string
> > > > > > >
> > > > > > > strVar2 = "Hello World!"
> > > > > > >
> > > > > > > strVar1 = "strVar2"
> > > > > > >
> > > > > > > Can I get the value of strVar2 by referencing strVar1? I could
> > > > swear
> > > > > > there's
> > > > > > > a way to do it but I can't remember how! L
> > > > > >
> > > > > > You must be asking something deeper than the words you used to
ask
> > > > this
> > > > > > question... doesn't simply
> > > > > >
> > > > > > strVar1 = strVar2
> > > > > >
> > > > > > do what you are asking? Or are you asking for some kind of
> permanent
> > > > > > linkage so that after changing the contents of strVar2 somewhere
> > > > inside
> > > > > > of your program, strVar1 will automatically mirror that change
> > > > without
> > > > > > making the above direct assignment? If that is what you are
after,
> > > > no,
> > > > > > VB doesn't do this. However, in 20+ years of programming in
> > > > BASIC/VB, I
> > > > > > can honestly say I've never come across the need to do this.
What
> is
> > > > > > your program doing (that is, what is it in your program's logic)
> > > > that
> > > > > > makes such a linkage necessary? Since I can't imagine the
> situation
> > > > > > requiring this, I'd really like to know.
> > > > > >
> > > > > > Rick - MVP
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: Runtime macros
    ... > be a static type to the programmer). ... > as a macro rather than a function, and at runtime, the macro could examine ... > declarations again (except for those cases where it wouldn't be possible ... You could have a special defun type form that checks if it has yet been ...
    (comp.lang.lisp)
  • Re: ANSI C Challenge on readint
    ... If you can't type out 'for', you'll never make it as a programmer. ... Don't define a macro to do a standard subroutine's job. ... > * be possible preserve the state of stream for the use of scanf, ... "Makes hackers smile" makes hackers smile. ...
    (comp.lang.c)
  • Re: A Macro to Generate Jump Tables
    ... > Although your macro is indeed powerful, and I can see some value in using ... you have described your macro as "A Macro to Generate Jump ... programmer would write when creating a multi-way branch (i.e., switch) ...
    (alt.lang.asm)
  • Re: How to convert binary to hex using a macro?
    ... defined as a macro, won't be further replaced). ... I tried to use HEX_ and Ox to provide the extra level of indirection - ... or a single space. ...
    (comp.lang.c)
  • Re: Runtime macros
    ... >>>be a static type to the programmer). ... >>>as a macro rather than a function, and at runtime, the macro could ... >>>declarations again (except for those cases where it wouldn't be possible ... >> You could have a special defun type form that checks if it has yet been ...
    (comp.lang.lisp)