|
-
Jan 11th, 2002, 03:54 PM
#1
Thread Starter
Fanatic Member
Variable names from strings?
hey,
i'm pretty sure this cant be done, but just makin sure...
is it possible to declare and reference a variable that has a name taken from a string?
this sort of thing...
VB Code:
Dim strString as string
strString = "varVariable"
Dim [B]strString[/B] as variant
-
Jan 11th, 2002, 04:05 PM
#2
Frenzied Member
Not that I know,
Why would you want to anyways?
-
Jan 11th, 2002, 04:21 PM
#3
New Member
New project of ours 
We're not releasing any public details yet... gotta make sure it'll work 
Hydrox0r
CEO - Dev Sibwarra
-
Jan 11th, 2002, 05:51 PM
#4
New Member
::: makes a Tarzan-like call for help :::
HELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLPPPPPPPP
(please)
Hydrox0r
CEO - Dev Sibwarra
-
Jan 11th, 2002, 06:06 PM
#5
You can't do that directly, but you can achieve the same effect. If you want to have a set of user-defined variables and user-defined names for them, you can do something like the following:
Dim strUserDefinedVariable(100,2) As String
' Then, use strUserDefinedVariable(intVar,1) to hold the User Specified variable name,
' And use strUserDefinedVariable(intVar,2) to hold the corresponding value for that User Specified variable name.
I've used this technique when writing my own script file or command file interpreter programs. It allows the user to make up and use his own variable names (and corresponding values for them), while I can store and keep track of them so they can be referenced as needed.
-
Jan 11th, 2002, 06:29 PM
#6
Addicted Member
Now this if going back a bit but ...
I rember from various other languages I have used in the past there is a function - normaly called something like eval - that does this sort of thing.
Everso
-
Jan 11th, 2002, 06:38 PM
#7
New Member
Hmm... can't find anything like that in VB... it's kinda an object orientated thing I'm trying to do - like:
(this doesn't work)
Dim strVar
strVar = "testing"
Dim strVar as New Form1
(need a variable named as the contents of the strVar variable)
so the finished product would be a new instance of Form1 referenced by the variable "testing".
CEO - Dev Sibwarra
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
|