|
-
Jan 26th, 2009, 10:12 PM
#1
Thread Starter
Junior Member
[RESOLVED] VBA Questions about Variables
1. I wanted to know if a code can be written to make more variables if needed? I am asking the user on a userform for a list if information. I would like to set each item that is listed on the form to be set to a different variable, and I would like to let the user have as many items they list as they like. So, I would like the code to create the number of variables to match the list of items provided by the user. For example, if there are 2 items, the program could create MyVar1 and MyVar2. Most of the time it will just be 8 variables; however, I could see in the future there being a need for possibly 30 or more variables. I would like to keep it flexible.
As a last resort, I could list the items on a hidden page and refer to that page as needed; however, I was trying to avoid that.
2. I was also wondering how the computer allocates space for variables. Specifically, if you have a private sub within your program that declares variables, but when the person used the program, they never used that portion of the code, would the computer allocate memory for those unused variables? If not, I could create private subs that are rarely used that house more variables.
3. I was also wondering if textboxes, command buttons, labels, etc. are all considered variables. Should I declare each of them? If so, what do I declare them as? A string? An object?
4. I have the user fill in data in a bunch of textboxes on a userform. With each answer, I am setting a new variable equal to the textbox that I then use in the program. Should I just be using the textbox as a variable and not have new variables for that information?
Thanks,
Teddy
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
|