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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing form name to a function

Status
Not open for further replies.

doramsey

Programmer
Sep 13, 2001
12
US
Using VB 6, I'm trying to pass the name of a form from the form to a function outside the form and then reference the form in the function. Need help.
 
Two suggestions:

1) Use GetObject()

2) Don't pass just the form's name, pass the form itself.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
I would second Chip here - pass a reference to the form itself...

mmilan
 
Function fnName (frm as Form)
frm.Caption="Function Worked!"
End Function

....
....
fnName Form1

-----------------------------------------------------------
If you are so adament you should pass the form Name itself then, modify it like this.

Function fnName (frmName as String)
Dim frm as Form
Dim frmTmp as Form

For each frmTmp in Forms
If frmTmp.Name=frmname then
set frm=frmTmp
GoTo exitLoop
end if
Next

exitLoop:
frm.Caption="Function Worked!"
End Function

....
....
fnName Form1.Name

------------------------------------------
The faulty interface lies between the chair and the keyboard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top