Hi,
Im trying to make an order for an invoice that will take in some details like name, number and have an array of product details like price, qty. It uses variables used in class mods. See if you can make sense of this.

Sub webservicetest()

    Dim NewOrder As New struct_XOrder
    Dim LineItems(1 To 2) As New struct_LineItem

    NewOrder.ClientShortName = "DemoClient"
    NewOrder.OrderNumber = "12345"

    LineItems(1).Qty = 5
    LineItems(1).ItemComment = "comment1"
    'LineItems(2).Qty = 10
    'LineItems(2).ItemComment = "comment2"

    Debug.Print NewOrder.ClientShortName
    Debug.Print NewOrder.OrderNumber
    'Debug.Print NewOrder.LineItems(1)


    '''''''''''' Sample C# code - trying to replicate
    NewOrder.LineItems = new LineItem[2]; // initialize to correct number of line items
    LineItem XLine;
    XLine = new LineItem();    // create a new line item
    XLine.ClientShortName = "abcde";         // populate it
    XLine.Qty = 5;
    NewOrder.LineItems[0] = XLine;      // place it to the array
    XLine = new LineItem();             // and so on
    XLine.Qty = 10;
    Xline.ClientShortName = "test";
    NewOrder.LineItems[1] = XLine;
    ''''''''''''''


End Sub

First off are you in the right forum? Your code looks like VB.net not VB6. Secondly, if this is VB.net then, I'd use nested classes and lists instead of arrays. List work much the same with one important aspect, they are more dynamic and support growing and shrinking as items are added or removed.

Its actually vba. Im not sure if this should be in vb6 or vb.net. Im trying to recreate that bit of c# code but im not having much luck.

If it's vba this is the right place. But you're facing an uphill battle here. C# is accessing the worksheet in a different manner than you will. Basically you want to design the form in excel first then access the parts of the form using the Worksheet object.

Unless you specifically need features of excel, that are hard to duplicate, you might be better off using a series of forms in .net.

Ok thanks for the advice.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.