469,167 Members | 2,109 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,167 developers. It's quick & easy.

Variable Variables in Visual Basic

11
Hey. I was wondering how I would be able to make a variable that has a name that contains another variable. I want to create a bunch of tabpages for files that have names that are like tab_filename. I know in php you could do ${$var} = "data";
How would i go about this in vb? thanks
Sep 18 '07 #1
4 2700
Dököll
2,364 Expert 2GB
If we're talking strings, you can say:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim MyVariable, MyMethod
  3.  
  4. MyVariable = Doolittle
  5.  
  6. MyMethod = ...
  7. ...
  8.  
  9. If Doolittle Like "Lalala" Then 
  10.  
  11.   This or that
  12.  
  13. End If
  14.  
  15. ...
  16.  
  17.  
Please stay tuned, give other experts some time to see this, provide some added examples for you.

Get a load of this site while you wait: http://functionx.com/vb/Lesson04.htm
Sep 18 '07 #2
Killer42
8,435 Expert 8TB
One possibility might be to store them in a collection, which allows you to use a string as the index to retrieve them. So for instance you could access something in the TabName collection by referencing TabName(FileName).
Sep 18 '07 #3
BaKo
11
Thanks, that solves the tabpage problem, but I also need to create whole new tabControls for each file, and I can't use a collection of tabControls, just pages. Any ideas? Is there a way to increment variable names maybe? Thanks alot!
Sep 18 '07 #4
Killer42
8,435 Expert 8TB
Thanks, that solves the tabpage problem, but I also need to create whole new tabControls for each file, and I can't use a collection of tabControls, just pages. Any ideas? Is there a way to increment variable names maybe? Thanks alot!
Hm... apart from arrays, the only way I can think of to "increment variable names" would be to use something like the Microsoft Script Control and try to build code dynamically at runtime and execute it. I don't have any experience with this, but it has been mentioned once or twice in earlier threads - you could try some searching.

If so, also try searching on Microsoft Scripting Runtime (although that's also used for the FileSystemObject model, and will show up much more frequently).
Sep 18 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Luis Solís | last post: by
83 posts views Thread by Alexander Zatvornitskiy | last post: by
134 posts views Thread by James A. Donald | last post: by
4 posts views Thread by Lucy | last post: by
3 posts views Thread by dotNETnews | last post: by
2 posts views Thread by Hamish Symington | last post: by
reply views Thread by Wendy Elizabeth | last post: by
4 posts views Thread by Diffident | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.