|
-
May 31st, 2002, 09:41 PM
#1
Thread Starter
Lively Member
Visual Basic for Applications
Any VBA experts out there that know the right syntax to pass a control as a parameter of a subroutine?
For example:
Code:
Private Sub ChangeEnabled(Generic as Textbox)
Generic.Enabled = not(Generic.Enabled)
End Sub
Private Sub Main
Call ChangeEnabled(Me!myTextbox) 'This doesn't work
End Sub
Thanks for any help,
Jeff
-
May 31st, 2002, 10:02 PM
#2
Hyperactive Member
Private Sub Main
Call ChangeEnabled(Me.myTextbox)
End Sub
-
Jun 1st, 2002, 12:23 AM
#3
PowerPoster
I don't know about VBA, but in VB you can declare a control as a generic control if you need to. For example, if you wanted to populate a list, you would want to be able to pass a listbox or a combobox:
VB Code:
Sub PopulateList (lst As Control)
If TypeName(ctl) <> "ListBox" And TypeName(ctl) <> "ComboBox" Then
Exit Sub
End If
' Do something with control here
End Sub
-
Jun 1st, 2002, 03:20 AM
#4
Thread Starter
Lively Member
Thanks for the responses.
You are both right.
My problem was that I had imported an MSFlexGrid and yet my subroutine would not accept:
Code:
Private Sub SetupFlex(myFlex as MSFlexGrid)
I changed it to:
Code:
Private Sub SetupFlex(myFlex as control)
and it works great now.
Thanks for the help,
Jeff
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
|