|
-
Apr 2nd, 2003, 04:40 PM
#1
Thread Starter
New Member
Creating / naming variables on the fly
Hi there wonderful people....
I have designed a form which contains 57 textboxs. As this form is in Access and not VB, I cannot do control arrays.. So I need to declare them individual as shown below:
<Visual Basic>
textbox1 = myArray(1)
textbox2 = myArray(2)
textbox3 = myArray(3)
textbox4 = myArray(4)
...
...
...
</Visual Basic>
I would like to be able to this on the fly in a loop as shown below:
</Visual Basic>
while index < 4
textbox<index> = myArray(index)
Wend
</Visual Basic>
In php it is done by naming one variable from two or more other variables on the fly such as below:
<PHP>
myVariable = textbox;
$index = 0;
while($index < 4)
{
$$myVariable$index = myArray($index)
}
</PHP>
I don't know if there is a way of pointing to locations, etc
-
Apr 2nd, 2003, 05:55 PM
#2
Stuck in the 80s
If you set your TextBoxes up as a control array, ie txtBox(0) - txtBox(3), you can easily accomplish it like so:
VB Code:
For i = 0 to 3
txtBox(i).Text = myArray(i)
Next
To set the TextBoxes as a control array, you must specify an index in the properties window and name all the boxes with the same name (ex txtBox).
-
Apr 2nd, 2003, 05:58 PM
#3
Stuck in the 80s
Nevermind. I somehow missed the part where you said "I can't use a control array."
I do not believe there is anyway to name variables on the fly, unless the scripting library works that way.
Give me a minute to find some code...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|