473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2827
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

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

Similar topics

4
by: Luis Solís | last post by:
Hi It is possible to declare some variables as int, long... ? , or something like visual basic option explicit. In some situations could be usefull. Thanks
83
by: Alexander Zatvornitskiy | last post by:
Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
4
by: Lucy | last post by:
In the Declarations section of a form's code module, what is the difference between the following: Dim Flag As Boolean Public Flag As Boolean Private Flag As Boolean Thanks!
3
by: dotNETnews | last post by:
Little confused... When I declare a namespace variable in module I can use it anywhere in the project. That's clear. I read a book in which the author said that namespace variables can be...
2
by: Hamish Symington | last post by:
Hello, I'm trying to re-code a site which I wrote in PHP into ASP.NET using Visual Basic .NET. Something PHP has which has proved invaluable is the concept of variable variables. I haven't...
0
by: Wendy Elizabeth | last post by:
I am currently working with Visual Basic.net in the Vistual Studio.net 1.1. When I want to look at values in different variables, I will put my mouse over a field (hover of the variable). When I...
5
by: juan | last post by:
Hello, I have a web project in Visual Basic 2005. I want to create a session variable in the "global.asax" file as an array of strings type. The syntax I use is the following: ...
4
by: Diffident | last post by:
Hi All, I am trying to perform a non-CPU bound operation in an asynchronous fashion using 'Thread' and a delegate. Basically, I am spawning a thread using ThreadStart and Thread. My non-CPU...
1
NeoPa
by: NeoPa | last post by:
Problem Description : In VBA there is an option to enforce declaration of variables in your code. With this set, any reference to a variable that has not been previously declared (Dim; Private;...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.