|
-
Oct 19th, 2004, 01:53 PM
#1
Thread Starter
Hyperactive Member
[Resolved] Multiple instances of ActiveX at runtime?
I'd swear I've seen this done, but can't remember how.
I'd like to create an array of an activex component at runtime so that I can access multiple instances of it.
Something like this pseudo-code:
Code:
Dim AXarray() as myActiveX
Private Sub Form_Load()
ReDim AXarray(2)
AXarray(0).load "myfile"
AXarray(1).load "yourfile"
AXarray(2).load "ourfile"
End Sub
Can someone please help?
Thanks.
Last edited by wayneh; Oct 20th, 2004 at 06:31 PM.
-
Oct 20th, 2004, 12:18 PM
#2
Try using a collection.
VB Code:
Option Explicit
'
Private m_colControls As Collection
'
Private Sub cmdCreate_Click()
Dim myControl As Collection
Dim i
'
Set m_colControls = New Collection
'
For i = 1 To 10
Set myControl = New Collection
myControl.Add CStr(i)
m_colControls.Add myControl
Set myControl = Nothing
Next
'
End Sub
Private Sub cmdDisplay_Click()
Dim Control As Collection
'
For Each Control In m_colControls
Me.lstContainer.AddItem Control.Item(1)
Next
'
End Sub
-
Oct 20th, 2004, 06:31 PM
#3
Thread Starter
Hyperactive Member
I found this solution on another Forum - works perfectly!
Place one instance of the OCX on your form and give it an Index of 0. This creates a control array. During run-time you can load new instances of the control by using the Load keyword. Example follows:
'Loading new instances of a control at run-time
Dim i As Long
'Get the next index to load
i = TheOCX.UBound + 1
'Load a new instance of the OCX control
Load TheOCX(i)
TheOCX(i).Visible = True
TheOCX(i).Text = "TheOCX " & CStr(i)
'and so on...
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
|