Results 1 to 3 of 3

Thread: 2 dimensional join function

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    2 dimensional join function

    this is to simply join a 2 dimensional array with 2 delimiters
    accepts any type of array, returns a string
    vb Code:
    1. Function join2(myarr, chr1 As String, chr2 As String) As String
    2. Dim mystr As String, i As Integer, j As Integer
    3. mystr = ""
    4. For i = LBound(myarr, 1) To UBound(myarr, 1)
    5.     For j = LBound(myarr, 2) To UBound(myarr, 2) - 1
    6.         mystr = mystr & CStr(myarr(i, j)) & chr1
    7.     Next
    8.     mystr = mystr & CStr(myarr(i, j)) & chr2
    9. Next
    10. join2 = mystr
    11. End Function

    call like
    vb Code:
    1. Debug.Print join2(myarr, vbTab, vbNewLine)
    Last edited by westconn1; Aug 18th, 2010 at 04:52 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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