
Dim a Variable from a string???Possible??
Ben,
Quote:
> I noticed that while you disagree, at the same time you yourself call it
a
> variable. So I ask you:
A variable in the sense that it's a memory address with a modifiable
value. But I cannot bring myself to think of collection or array indices
as "variables" in the "Dim X As Y" type of memory allocation through a
compiler-recognized symbolic name.
Quote:
> -- Was the memory allocated before the new item was added, or was it
> allocated to make room for it?
The array grew dynamically by so many bytes to hold an indexed pointer to
a new address with a new value. *Where* the address is need not concern us
-- just the fact that I can access it through an index or a key. I
consider an array index to be part of the variable that the array actually
is. So, again, I can't call it a variable all by itself.
Quote:
> -- Does the fact that the value is contained in an "indexed sequence" of
> addresses make it any less a variable? If so, then what do you call an
> array?
Again, the variable is the array. Individual items inside the array are
not, IMO, variables. Well, they are, but not in the strict sense of the
word.
Quote:
> >and then using a
> >key (or index) to gain access to that address.
> Any variables you declare within your own code are accessed through keys
and
> indexes.
No, that's the difference. An array index does not have a symbolic name.
Just an index *into* a symbolic name, because the container --if you
will-- is the array, which does have a symbolic name.
Quote:
> The "Dim" keyword stands for "Dimension", which essentially means making
> room in memory for a new value. When you add an item to a collection,
the
> collection must be re-*dimensioned* to hold it. The fact that you access
it
*Dimension* is the act of allocating space either on the stack or on the
heap, *before* the program or the procedure is actually executed. Adding a
new item to an array just grows the memory address to hold the new
item(s). Granted, in terms of memory allocation it is theoretically the
same thing, but the difference --and I think we've gotten away from the
purpose of the original post-- is that you cannot "create" a symbolic name
from another one, or from the value of another variable or whatever. I
don't think that's a limitation of any language. It's just how computer
languages work. Thus Bob Butler's suggestion of using a collection creates
a viable alternative to the original impossible question.
Quote:
> via a string has nothing to do with whether it is a variable or not. As
far
> as VB is concerned, your "selector" or "symbolic name" is a string (or
> "key") in the code window, and an index once compiled.
Well, I guess I'm being argumentative Ben, but I see it differently from
you.
Quote:
> Don't think that just because the Dim keyword wasn't used, the value
cannot
> be a variable.
Uhmpf. Again, it is a variable in the sense that it's an indexed address
of memory whose value can be modified. But it does not have a symbolic
name. The array holds the symbolic name, and everything else goes through
that. "Redim" in VB is used to grow or shrink an existing array, not to
create new, independent variables with their own symbolic names.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Best regards,
Klaus H. Probst, MCP
ICQ: 22454937
The VB Box: http://members.xoom.com/kprobst/
~~~~~~~~~~~~~~~~~~~~~~~~~~~