Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 27th, 2006, 01:07 PM
Authorized User
Join Date: Nov 2005
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing jagged array to com object

Alas, I feel I am asking for it now.

I am trying to pass a jagged array of object to a component service.

In vb.net

I define the array as:
Dim orderLines()() As Object = New Object(10)() {}

For testing I do a VERY simple load:

orderLines(0) = New Object(3) {}
        orderLines(i)(0) = CInt(txtLineNo.Text)
        orderLines(i)(1) = txtPartID.Text
        orderLines(i)(2) = txtShipToID.Text
        orderLines(i)(3) = txtCommodityCode.Text

I call my com object trying various formats such as:

blnIsOrderValid = connection.IsOrderValid(varCustomerID, varShipVia, varFreightTerms, varLongDescription, _
                varShipToAddrNo, orderLines(10))

blnIsOrderValid = connection.IsOrderValid(varCustomerID, varShipVia, varFreightTerms, varLongDescription, _
                varShipToAddrNo, orderLines(10)(3))
            blnIsOrderValid = connection.IsOrderValid(varCustomerID, varShipVia, varFreightTerms, varLongDescription, _
                varShipToAddrNo, orderLines)


Com object is set up as:
IsOrderValid(ByVal CustomerID As String, ByVal ShipVia As String, ByRef FreightTerms As String, ByRef LongDescription As String, ByVal ShipToAddrNo As Integer, OrderLines() As Variant) As Boolean

Note calling my com object was working just fine until I tried to pass the jagged array of objects OrderLines().

But now I get messages like:
Error msg: Object reference not set to an instance of an object.
Error msg: Subscript out of range.
Error msg: Specified array was not of the expected type.

Is there a simple code example I could follow?
I would very much like to keep the jagged array or objects of objects passed to a com object.

From Shakespeare: 'Lay on McDuff!'

I feel a sword about to fall.

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing jagged array of objects nutrino Beginning VB 6 0 January 27th, 2006 11:58 AM
jagged array help oozener C++ Programming 1 December 4th, 2005 10:45 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
jagged array problems, who can help me? hlchuah77 C# 2 July 1st, 2004 10:37 AM
Passing an array in a Sub krunch97 VB.NET 2002/2003 Basics 1 May 4th, 2004 01:29 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.