I am trying to create an array with defined elements. I have a class file called struct_message:
I then wish to create an array object an assign the various elements to each index. Is this correct? My current code is:
When I run the code I'm getting a Subscript Out of Range error. This is for use to upload using a SOAP service. Any ideas why I can't assign the indexed elements?
Code:
Public originator As String
Public recipient As String
Public body As String
Public messagetype As String
Public validityperiod As Long
I then wish to create an array object an assign the various elements to each index. Is this correct? My current code is:
Code:
Sub BuildArray()
Dim aMessages() As struct_message
For i = 1 to 5
aMessages(i).originator = "Test"
aMessages(i).recipient = "Someone's Name" 'This will be changed to cycle through the recipients
aMessages(i).body = "The Message" 'This will be changed to cycle through individual messages
aMessages(i).messagetype = "Text"
aMessages(i).validityperiod = 0
Next i
End Sub
When I run the code I'm getting a Subscript Out of Range error. This is for use to upload using a SOAP service. Any ideas why I can't assign the indexed elements?