Rookie
09-01-2003, 04:16 AM
how do i pass a string to point to an object? Ie: at run-time the user types ... MakeSurface(SurfName)
and then I read the input so that NameOfSurface$ = "SurfName"
What i want to do is create a sub that I can call as follows...
Call Create_Surface(NameOfSurface$)
then in the sub it will create a surface called "SurfName" or whatever the user of the program specifies.
gundavarapu
09-01-2003, 05:25 AM
Is it that, you want the variable name passed instead of the Value of the variable?
Rookie
09-01-2003, 05:34 AM
no.
say the user type some text. I want to create a variable or object with the name being the text the user typed.
EXAMPLE:
//user types into a textbox...."Hello"
//now I want to create a variable called "Hello".
//so, I cant just go...
Dim Hello as DirectDrawSurface7
//...because I dont know that the user will actually type "Hello" it could be anything.
...
get what i mean?
Dim ("Hello") as DirectDrawSurface7 //Doesn't work but to show u
//I want the string contents as the variable name.
Thinker
09-01-2003, 09:00 AM
You can't create variables at run time. You can redim dynamic arrays
and add values/objects to collections. Those are your only two ways.
vbfan
09-01-2003, 01:11 PM
You can do that. but you have to use the Ms ScriptControl(the only Control for Scripting I know).
But with MS ScriptControl you have the Problem you can't create Vars as any Datatype they're all as Variant declared.
Anyway a possible way:
Private Sub Command1_Click()
ScriptControl1.AddCode "Dim " & Text1.Text
End Sub
And you would have there a Variable which will be as Variant.
Rookie
09-01-2003, 01:37 PM
Ok, thanx. I guess now im going to have to create an array of surfaces and an array of tags. It shouldnt be too muxh work.