Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem passing UDT array from client to control (using ActiveX DLL)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi all,

I've created an ActiveX control (OCX) that references a UDT in an ActiveX DLL I also created. I've put the control in a client project and also referenced the UDT. The problem occures when I try to pass a an array of the UDT from the client as a parameter to a method of the control. I get the "ByRef argument type mismatch" error.

I know the references in VB have been set for each of the client and control projects, and the DLL class is public. The DLL isn't in the Windows/System directory, but I have manually registered it with "regsvr32" from where it is.

I just can't figure out what is wrong. I've included the relavant code below and any help will be much appreciated


-- DLL Class code --

VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsMain"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Public Type TimeSet
Time As Single
Key As Integer
End Type


-- Control Method code [JTimer] --
Dim arrTickTimes() As TimeSet

Public Sub GiveTimeList(InputList() As TimeSet, EleNo As Integer, _
iLower As Integer, iUpper As Integer)

ReDim Preserve arrTickTimes(iLower To iUpper)

arrTickTimes(EleNo) = InputList(EleNo)
lstTimes.AddItem arrTickTimes(EleNo).Key & " " & arrTickTimes(EleNo).Time

arrUpper = iUpper
arrLower = iLower
End Sub


-- Client code --
Private Sub Command1_Click()
Dim Times(1 To 3) As TimeSet

Times(1).Key = 1
Times(1).Time = 0.334
Times(2).Key = 2
Times(2).Time = 1.435
Times(3).Key = 3
Times(3).Time = 0.094

Call JTimer1.GiveTimeList(Times(), 1, 1, 3)
End Sub


As a side note, I used this as a solution to the problem that was perfectly described and *sovled* in an MSDN article (Q224185 - FIX: User Defined Type in Public Function of a User Control Fails to Run) found at
--
Thanks,
Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top