1
我試圖使用一些類,將持有發票數據,我似乎無法得到它的工作。我只是希望它能夠在數組中保存發票的詳細信息。繼承人的代碼,也許有人可以弄明白。 同樣id爲LineItems採取隨機數量的產品項目,不確定如何做到這一點。我這樣做最終通過ms訪問的web服務發送數據。訪問VBA類數組
這裏是struct_XOrder其他代碼:
Public OrderNumber As String
Public ClientShortName As String
'"LineItems" is an array with elements defined as struct_LineItem
'See Complex Types: Arrays in Microsoft Office 2003 Web Services Toolkit Help
'for details on implementing arrays.
Public LineItems As Variant
Public OrderError As String
繼承人的struct_LineItem:
Public ProductSKU As String
Public Qty As Long
Public UnitPrice As Variant
Public ItemComment As String
Public ItemError As String
繼承人我主要的代碼
Sub webservicetest()
Dim NewOrder As struct_XOrder
Dim LineItems(1 To 2) As Variant
Dim Xline(1 To 2) As Variant
Set Xline() = struct_LineItem
Set NewOrder = New struct_XOrder
Set NewOrder.LineItems() = New struct_LineItem
Set NewOrder.LineItems() = New Xline
'Xline = New struct_LineItem
Xline(1).ItemComment = "items"
Xline(1).Qty = 10
NewOrder.LineItems() = Xline()
NewOrder.ClientShortName = "DemoClient"
NewOrder.OrderNumber = "12345"
'Xline(1).ItemComment = "item1"
'Xline(1).Qty = 5
Debug.Print NewOrder.ClientShortName
Debug.Print NewOrder.OrderNumber
'For i = LBound(Xline) To UBound(Xline): Debug.Print Xline(i): Next
'Debug.Print Xline(1).ItemComment
'Debug.Print Xline(1).Qty
End Sub
非常感謝。這樣做更有意義。 Il玩弄它,讓它做我想做的事。 – Col
struct_xorder類模塊被改變了,有沒有辦法讓我把它保留爲'lineitems as variant'?它造成錯誤。 @enderland – Col
BTY這個webservices位於https://webservices.p3pl.com/WSOrder.asmx?WSDL,如果這有助於任何人更好地理解。 – Col