Help with accessing an object

lution

Registered User.
Local time
Today, 01:58
Joined
Mar 21, 2007
Messages
114
I've added a reference to a vb.NET .tlb file. One of the methods in it is:

Code:
Public Function getMessageList(ByVal agency As Agency) As <System.Xml.Serialization.XmlElementAttribute("receipt")> Receipt
            Dim results() As Object = Me.Invoke("getMessageList", New Object() {agency})
            Return CType(results(0),Receipt)
End Function

The Receipt class is defined as:
Code:
    Partial Public Class Receipt
        
        Private referenceField() As Reference
        
        Private confirmationField() As Confirmation
        
        Private idField As String
        
        Private timestampField As Date
        
        Private timestampFieldSpecified As Boolean
        
        Private agencyidField As String
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute("reference", IsNullable:=true)>  _
        Public Property reference() As Reference()
            Get
                Return Me.referenceField
            End Get
            Set
                Me.referenceField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute("confirmation", IsNullable:=true)>  _
        Public Property confirmation() As Confirmation()
            Get
                Return Me.confirmationField
            End Get
            Set
                Me.confirmationField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlAttributeAttribute()>  _
        Public Property id() As String
            Get
                Return Me.idField
            End Get
            Set
                Me.idField = value
            End Set
        End Property

If I create a vb.NET usage of this to get all the receipts I do something like this:

Code:
     Dim messageListReceipt As ECitationService.Receiptservice.getMessageList(agency)

     'Now iterate through the list of reference IDs and retrieve
     'the actual info.
     For i As Integer = 0 To messageListReceipt.reference.GetUpperBound(0)

       Dim messageId = messageListReceipt.reference(i).id

     Next

I'm trying to do the same thing in VBA but I'm having trouble being able to get all the messageID's. I'm not sure if it's my variable declarations or how I'm trying to use them. A very basic sample of where I'm at right now (with all the other stuff stripped out):

Code:
Private Sub fillMessagesButton_Click()
Dim myMessages As Long
Dim myTrACS As BadgerTracks2010.QuickClerkBTrACS
Dim myAgency As BadgerTracks2010.Agency
Dim myService As ECitationService
Dim messageListReceipt As BadgerTracks2010.Receipt
Dim i As Long
Dim citationSuccessful As Boolean
Dim messageID As String
    
        
        Set myTrACS = New BadgerTracks2010.QuickClerkBTrACS
        Set myService = myTrACS.getTrACSService(Me.txtUserName, Me.txtPassword)
        Set myAgency = New BadgerTracks2010.Agency
        myAgency.id = Me.txtUserName
        myMessages = myService.getMessageCount(myAgency)
        
        
        Debug.Print "Message count: " & myMessages
        
        If myMessages > 0 Then
    
            Set messageListReceipt = myService.getMessageList(myAgency)
            For i = 0 To (myMessages - 1)
            
                messageID = messageListReceipt.id
            
                Debug.Print "Message #: " & i & ", " & messageID
                
            Next
                
        End If
                
End Sub

This keeps printing the same messageID. If I change the line

messageID = messageListReceipt.id

to

messageID = messageListReceipt.Reference(i).id to match the way it works in VB.NET I get "wrong number of arguments or invalid property assignment" error message.

Could someone please point me to why I can't loop through all the message ID's in the messagelist in VBA like I can in vb.NET?

Thanks
Lution
 

Users who are viewing this thread

Back
Top Bottom