Results 1 to 3 of 3

Thread: Extracting information from a multidimensional array ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2013
    Posts
    15

    Extracting information from a multidimensional array ?

    I've tried just about every possible combination of code to extract just the first name from a multidimensional array set for only the first and last name. All I can get is the first name "Bob" which is positioned first in the array. The rest come out as a few letters of both the first and last name. Can anyone show me something I missed here?

    Code:
    Private Sub btnPlaceOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaceOrder.Click
    
            Dim strName, strFirst As String
            Dim intSpace As Integer
            Dim Row As Integer
    
    
            Row = cboCusNum2.SelectedIndex
    
            If cboCusNum2.SelectedIndex < 0 Then
    
                MsgBox("Must select a customer number")
    
                Exit Sub
            End If
    
    
            strName = CustInfo(Row, 0)
            intSpace = strName.IndexOf(" ")
            strFirst = strName.Substring(Row, intSpace).TrimStart
    
    
            intTotalQty += nudQuantity.Value
            decTotalSales += decFinalTotal
    
            MsgBox("Order of " & FormatCurrency(decFinalTotal) & " For " & (strFirst))
    
            Exit Sub
    
        End Sub
    
    End Class
    Code:
    '   Global arrays for storing Customer Information
        Public CustNums() As String = {"1234", "3456", "5678", "7890"}
        Public CustInfo(,) As String = {{"Bob First", "One 1st St", "Single, MT"}, _
                                      {"Sue Third", "Three 3rd Ave", "Triple, AL"}, _
                                      {"Joe Fifth", "Five 5th Dr", "Quintuple, VT"},
                                      {"Ann Seventh", "Seven 7th Ln", "Heptagon, TX"}}

  2. #2
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Extracting information from a multidimensional array ?

    Hey william,

    It's probably this line
    Code:
    strFirst = strName.Substring(Row, intSpace).TrimStart
    Row changes as the selected index. The first name always starts at the first character of the string.

    Maybe:
    Code:
    strFirst = strName.Substring(0, intSpace).TrimStart

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2013
    Posts
    15

    Re: Extracting information from a multidimensional array ?

    Thanks Inferrd! That was it. I spent many hours on that problem. It's a relief.

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