From: Old Pedant on
> One more (hopefully quick) question... within the loops as shown in
> my code, does each variable created (e.g. strOutP1, strOutP2, etc)
> retain its value, or is an array needed for this?

Ummm...."loops"??? You only show ONE loop there.

And you don't show *ANY* variables name strOutP1 or strOutP2 or anything
similar to that.

What in the heck are you talking about??? Maybe code you didn't show us?


From: ll on
On Jun 1, 12:40 am, Old Pedant <OldPed...(a)discussions.microsoft.com>
wrote:
> > One more (hopefully quick) question... within the loops as shown in
> > my code, does each variable created (e.g. strOutP1, strOutP2, etc)
> > retain its value, or is an array needed for this?
>
> Ummm...."loops"??? You only show ONE loop there.
>
> And you don't show *ANY* variables name strOutP1 or strOutP2 or anything
> similar to that.
>
> What in the heck are you talking about??? Maybe code you didn't show us?



Sorry for the confusion - allow me to just start from the beginning,
which might be easier. I have a set of variables
(strOut1_a....to...strOut15_a).
I'm looking for a way to loop through these variable names to
establish their values, such as:

strOut1_a = objComm("Out1_a")

but with a loop, rather than writing out each.
Many thanks again,
Louis
From: Anthony Jones on
"ll" <barn104_1999(a)yahoo.com> wrote in message
news:c68d58b2-58c7-4f03-b556-b1d3a5e3744a(a)k30g2000hse.googlegroups.com...
> On Jun 1, 12:40 am, Old Pedant <OldPed...(a)discussions.microsoft.com>
> wrote:
> > > One more (hopefully quick) question... within the loops as shown in
> > > my code, does each variable created (e.g. strOutP1, strOutP2, etc)
> > > retain its value, or is an array needed for this?
> >
> > Ummm...."loops"??? You only show ONE loop there.
> >
> > And you don't show *ANY* variables name strOutP1 or strOutP2 or anything
> > similar to that.
> >
> > What in the heck are you talking about??? Maybe code you didn't show
us?
>
>
>
> Sorry for the confusion - allow me to just start from the beginning,
> which might be easier. I have a set of variables
> (strOut1_a....to...strOut15_a).
> I'm looking for a way to loop through these variable names to
> establish their values, such as:
>
> strOut1_a = objComm("Out1_a")
>
> but with a loop, rather than writing out each.


That can't be done, you need an array. I know thats already been said but
things in this thread seemed to have got over complicated for some reason.

Dim strOut_a(4)

' Stuff to assign values to the array elements


For i = 0 To UBound(strOut_a)
Response.Write strOut_a(i) & "<br />"
Next




--
Anthony Jones - MVP ASP/ASP.NET


From: Old Pedant on
> Sorry for the confusion - allow me to just start from the beginning,
> which might be easier. I have a set of variables
> (strOut1_a....to...strOut15_a).
> I'm looking for a way to loop through these variable names to
> establish their values, such as:
>
> strOut1_a = objComm("Out1_a")
>

No, you do *NOT* want to do that. As a couple of people pointed out.

You WANT TO USE AN ARRAY.

Dim strOut_a(15)
For i = 1 To 15
strOut_a(i) = objComm("Out" & i & "_a")
Next

And then, where your *OTHER* code *WAS* using
strOut7_a
or whatever, you simply use
strOut_a(7)

What is wrong with that solution??

Now, there *IS* a way to do what you claimed to want. But it is slow slow
slow and clumsy and is not good programming practice and...well, the list
goes on. But if we truly can't convince you to use an array--perhaps because
some other component is expecting the indivdual names? if so, would you
really want to use that component?--then:

For i = 1 To 15
Execute "strOut" & i & "_a = objComm(""Out" & i & "_a"")"
Next

Untested, but I think that's right.

Ugly and slow code, though. Try hard to avoid it.