Results 1 to 13 of 13

Thread: [RESOLVED] converting List to Array

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2013
    Posts
    18

    Resolved [RESOLVED] converting List to Array

    Hello guys!

    I wanted to create two lists and then convert them to arrays, with the data from this table:

    idSuplier Item Price
    1 Item A 10.00
    1 Item B 20.00
    1 Item C 30.00
    2 Item A 20.00
    2 Item B 30.00
    2 Item C 40.00
    3 Item A 30.00
    3 Item B 40.00
    3 Item C 50.00

    Ok! the desired result would be: (1, 60.00); (2, 90.00) and (3, 120.00)

    So, I've tried the following code to create my array, but I haven't any results!

    Code:
    Private Sub List()
            
    
            Dim idSupplier As List(Of Integer) = New List(Of Integer)
            Dim sumSupplier As List(Of Decimal) = New List(Of Decimal)
            Dim value As Decimal
    
            For i = 1 To j
                For Each col As DataGridViewRow In dgItems.Rows
                    If col.Cells(0).Value = i Then
                        value = value + CDec(col.Cells(2).Value)
                        sumSupplier.Add(value)
                        idSupplier.Add(i)
    
    
    
                    End If
    
    
                Next
                
            Next i
            Dim idSupplierArray() = idSupplier.ToArray()
            Dim sumSupplierArray() = sumSupplier.ToArray()
    
            
            Console.ReadLine()
    
        End Sub
    Sorry if It seems so dumb, but its what I am...any hint?
    Last edited by goku99; Apr 11th, 2013 at 11:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width