|
-
Re: Passing an object name through a variable
Three choices:
1. Declare an object variable of the type required.
2. Declare a generic object variable of the type "Object"
3. Declare a variant type variable.
Here's samples of how to do it:
Private Sub Command3_Click()
Dim oT As TextBox
Set oT = Text1
oT.Text = "TextBox"
End Sub
Private Sub Command1_Click()
Dim o As Object
Set o = Text1
o.Text = "Object"
End Sub
Private Sub Command2_Click()
Dim v As Variant
Set v = Text1
v.Text = "Variant"
End Sub
You can also pass the object to a Sub or Function:
Private Sub PassTextBox( oT as TextBox)
oT.Text="PassTextBox"
End Sub
Private Sub Command4_Click()
PassTextBox Text1
End Sub
Please note that while I'm using a Textbox control as an object to pass
around inside the project, you can't pass the same to an Active X DLL (I
assume but haven't tried the same in a control). This is because VB wraps
controls inside its own extender library. You get a Type Mismatch Error (13)
if you try to.
cya,
mrfelis
Snip wrote in message <38c8cf84$1@news.devx.com>...
>
>I need to be able to pass the name of an object into a variable and the use
>the variable to alter that objects properties...
>
>eg.
>
>Variable1 = ActMod1.Name
>
>Variable1.value = 15
>variable1.ID = 0012
>
>etc.
>
>Does anyone know how to do this???
>
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks