Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a variable via a string

Status
Not open for further replies.

jonhodgkinson

Programmer
Mar 5, 2002
7
GB
Hi, is it possible through CF to referencing a variable via a string? i.e. I have the form variable 1_Email_145 and I want to get the value of this from by: function("1_Email_145")

I hope that makes sense, thanks for your help!
 
No. You can’t store the name of a form in a variable and reference the form using the variable. VB doesn’t work like that.
 
Well, if it is a public variable you can use the CallByName function.

Option Explicit
Public myVariable As String

Private TestCallByName()
Debug.Print CallByName(Form1,"myVariable",VbGet)
End Sub

Otherwise you can add a reference to the MS Script Lib and use the Eval function.
 
>You can’t store the name of a form in a variable and reference the form using the variable

Au contraire...
 
You certainly can - by using the .Eval method of a Scripting Object

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
you guys type too fast. :-D

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 


Now I'm not sure if they want the value of a public variable (a form property), or want to find/load a form using it's name in a variable.

Maybe jonhodgkinson can explain further...
 
I think that johnhodgkinson meant the former, and RonVaught was talking about the latter. We're covered both ways...:)
 

>>is it possible through CF to referencing a variable via a string

I think johnhodgkinson meant:
CF = Cold Fusion!!
They posted today the same question there.

Wonder why there was no response from johnhodgkinson here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top