Sep 13, 2004 #1 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.
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.
Sep 13, 2004 #2 chiph Programmer Jun 9, 1999 9,878 US 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 Upvote 0 Downvote
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
Sep 14, 2004 #3 mmilan Programmer Jan 22, 2002 839 GB I would second Chip here - pass a reference to the form itself... mmilan Upvote 0 Downvote
Sep 14, 2004 #4 vbSun Programmer Dec 9, 2002 504 US 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. Upvote 0 Downvote
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.