Results 1 to 2 of 2

Thread: Help!!! Join Function

  1. #1

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425

    Question

    I've got the Split function all figured out, but can't get the Join function working. As usual, MSDN Library was no help whatsoever, so I'm turning to the forums.

    Please could someone give me an example of the Join function at work?

    Thanks in advance!!

  2. #2
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Basically, you pass it an array (usually created with th Split Function) and it joins all the array's elements with the delimiter (usually a space):

    Code:
    Dim Joined As String, StartArr(2) As String
    
    StartArr(0) = "Hello"
    StartArr(1) = "There,"
    StartArr(2) = "CyberSurfer"
    
    Joined = Join(StartArr, " ")
    
    'Joined = "Hello There, CyberSurfer"
    If necessary you could use a different delimiter:

    Code:
    Dim Joined As String, StartArr(2) As String
    
    StartArr(0) = "Hello"
    StartArr(1) = "There,"
    StartArr(2) = "CyberSurfer"
    
    Joined = Join(StartArr, "@")
    
    'Joined = "Hello@There,@CyberSurfer"
    What it basically does is iterate through all of the elements, appending them to the delimiter and the string which the previous elements made:

    Code:
    Function MyJoin(Arr() As String, Delimter) As String
    'This is the same as Join:
    Dim TmpStr As String
    TmpStr = TmpStr & LBound(Arr)
    For i = LBound(Arr) + 1 To UBound(Arr)
         TmpStr = TmpStr & Delimter & Arr(i)
    Next:
    End Function
    I hope you understand it better, now.

    Me.


    Courgettes.

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