|
-
Aug 15th, 2000, 11:43 AM
#1
Thread Starter
Junior Member
I have a sample piece of code to look at a screen control
and report on its properties. For example:
Public Function fcnTest(strForm As String, _
strControl As String) As String
fcnTest = strScreen.strControl.Tag
End function
The problem comes in trying to get VB to replace strScreen and strControl with the form name and control name that is
stored in each variable. So, if one calls the function like
thus:
strSomething = fcnTest("frmMain", "ctlPushButton")
Inside my sample function should look like this, to VB
any how after the compiler get through with it:
Public Function fcnTest(strForm As String, _
strControl As String) As String
fcnTest = frmMain.cltPushButton.Tag
End Function
I am getting compile and run time errors.
Can anyone help me with this truly basic, too basic, query?
Thanks.
David L. Baudais
Systems Analyst
-
Aug 15th, 2000, 11:47 AM
#2
_______
<?>
strSomething = "fcnTest(""frmMain"", ""ctlPushButton"")"
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 15th, 2000, 11:55 AM
#3
Thread Starter
Junior Member
I do not understand or maybe I was not clear enough.
Doesn't this
strSomething = "fcnTest(""frmMain"", ""ctlPushButton"")"
just store what is inbetween double quotes into the variable
strSomething?
What I am trying to do is to come up with a generic function
so that I can pass the form name and the control name
and then manipulate the properties of the control.
Any more suggestions out there?
Thanks.
David L. Baudais
Systems Analyst
-
Aug 15th, 2000, 12:11 PM
#4
Why don't you pass object variables?
Instead of passing strings, you can pass a Form and a Control object. Even stronger: if you pass a reference to the control, you don't need to pass the form.
eg
Public Function fcnTest(MyControl As Control) As String
fcnTest = MyControl.Tag
End function
You could call the function like this:
strSomething = fcnTest(frmMain.ctlPushButton)
or like this
strSomething = fcnTest(Screen.ActiveControl)
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
|