From: xytsrm on
Problem"
Lets say that I have several variables defined:

Dim A As String
Dim B As String
Dim C As String

In the program I want to retain the references A,B and C, but I would like
to assign values to A, B and C by indexing. In other words what I would like
to create is an array of pointers [ie. Dim X(3)] to A, B, and C, such that by
equating X(1) = "message 1", then A = "message 1". VarPtr can be used to
make X(1) reference A by X(1) = VarPtr(A), but I'm not sure how to indirectly
assign "message1" to A via X(1). Perhaps there's an easier way? Can anyone
help?

X.

From: dpb on
xytsrm wrote:
> Problem"
> Lets say that I have several variables defined:
>
> Dim A As String
> Dim B As String
> Dim C As String
>
> In the program I want to retain the references A,B and C, but I would like
> to assign values to A, B and C by indexing. In other words what I would like
> to create is an array of pointers [ie. Dim X(3)] to A, B, and C, such that by
> equating X(1) = "message 1", then A = "message 1". VarPtr can be used to
> make X(1) reference A by X(1) = VarPtr(A), but I'm not sure how to indirectly
> assign "message1" to A via X(1). Perhaps there's an easier way? Can anyone
> help?

Afaik in VB your only option would be to use tricks such as the
CopyMemory API or an external language routine that allows such
equivalencing; VB does not have such a facility in the language.

--


From: Ralph on

"xytsrm" <xytsrm(a)discussions.microsoft.com> wrote in message
news:527FC413-4CF6-4AC2-B7C9-F8BF7EA6D3F2(a)microsoft.com...
> Problem"
> Lets say that I have several variables defined:
>
> Dim A As String
> Dim B As String
> Dim C As String
>
> In the program I want to retain the references A,B and C, but I would like
> to assign values to A, B and C by indexing. In other words what I would
like
> to create is an array of pointers [ie. Dim X(3)] to A, B, and C, such that
by
> equating X(1) = "message 1", then A = "message 1". VarPtr can be used to
> make X(1) reference A by X(1) = VarPtr(A), but I'm not sure how to
indirectly
> assign "message1" to A via X(1). Perhaps there's an easier way? Can
anyone
> help?
>

Yeah there is an easier way - don't go there.

VarPtr (along with StrPtr and ObjPtr) are undocumented functions to make it
easier to work with API calls that require addresses. ObjPtr does have some
use in identifying and tracking a specific Object within a VB application,
for the others knowing the address of something in VB is generally useless.

-ralph


From: xytsrm on
Thanks dpb,

I thought I had done this in VB along time ago, but it might have been
another language. The VarPtr does allow me to get the reference to the
variables; perhaps there's another undocumented function that would make the
indirect assignment.

X.


"dpb" wrote:

> xytsrm wrote:
> > Problem"
> > Lets say that I have several variables defined:
> >
> > Dim A As String
> > Dim B As String
> > Dim C As String
> >
> > In the program I want to retain the references A,B and C, but I would like
> > to assign values to A, B and C by indexing. In other words what I would like
> > to create is an array of pointers [ie. Dim X(3)] to A, B, and C, such that by
> > equating X(1) = "message 1", then A = "message 1". VarPtr can be used to
> > make X(1) reference A by X(1) = VarPtr(A), but I'm not sure how to indirectly
> > assign "message1" to A via X(1). Perhaps there's an easier way? Can anyone
> > help?
>
> Afaik in VB your only option would be to use tricks such as the
> CopyMemory API or an external language routine that allows such
> equivalencing; VB does not have such a facility in the language.
>
> --
>
>
>
From: Henning on
Poke?

No, soory just in the mode for it from discussions with some Scott ;)

/Henning

"xytsrm" <xytsrm(a)discussions.microsoft.com> skrev i meddelandet
news:44DEDE47-6104-448F-BCFD-C5FEAF8E897D(a)microsoft.com...
> Thanks dpb,
>
> I thought I had done this in VB along time ago, but it might have been
> another language. The VarPtr does allow me to get the reference to the
> variables; perhaps there's another undocumented function that would make
> the
> indirect assignment.
>
> X.
>
>
> "dpb" wrote:
>
>> xytsrm wrote:
>> > Problem"
>> > Lets say that I have several variables defined:
>> >
>> > Dim A As String
>> > Dim B As String
>> > Dim C As String
>> >
>> > In the program I want to retain the references A,B and C, but I would
>> > like
>> > to assign values to A, B and C by indexing. In other words what I
>> > would like
>> > to create is an array of pointers [ie. Dim X(3)] to A, B, and C, such
>> > that by
>> > equating X(1) = "message 1", then A = "message 1". VarPtr can be used
>> > to
>> > make X(1) reference A by X(1) = VarPtr(A), but I'm not sure how to
>> > indirectly
>> > assign "message1" to A via X(1). Perhaps there's an easier way? Can
>> > anyone
>> > help?
>>
>> Afaik in VB your only option would be to use tricks such as the
>> CopyMemory API or an external language routine that allows such
>> equivalencing; VB does not have such a facility in the language.
>>
>> --
>>
>>
>>