VBspeed / VB6 to VB5 / Join
VBspeed © 2000-10, updated: 29-Sep-2002
Join


The Definition
Function Join
Returns a string created by joining a number of substrings contained in an array.
Native to VB6, but not to VB5.
Declaration:
Join(SourceArray[, Delimiter])
Arguments:
SourceArrayRequired. One-dimensional array containing substrings to be joined.
DelimiterOptional. String character used to separate the substrings in the returned string. If omitted, the space character (" ") is used. If Delimiter is a zero-length string, all items in the SourceArray are concatenated with no delimiters.
Remarks:
VB6 Join handles the following special cases:
If SourceArray is not bound, Join returns a zero-length string.
If SourceArray has more than one dimension, Join raises error 5.

Since there is no easy way to check these conditions in VB, it's good enough for the emulations to leave this responsability with the calling code.
You may use this function (VB5/6-compatible) to verify the correctness of your emulation code.


The Charts
Calls
 sRet = Join(sArr, sDelim)
Call 1 sArr(): string array with 1000 elements of 10 chars each
sDelim: "" (zero-length string)
Call 2 sArr(): string array with 1000 elements of 10 chars each
sDelim: "," (comma)
Call 3 sArr(): string array with 100 elements of 10 chars each
sDelim: "," (comma)
Call 4 sArr(): string array with 100 elements of 100 chars each
sDelim: "," (comma)
 VB5
CodeAuthorDopingNotes
JoinVB6  
Join01 [traditional]  
Join02 [trad., impr.]  
Join03 JodyAPI 
Join04 JodyAPI 
Join05 Guido  
Join06 Keith  
Join07 Microsoft  
Join08 MattAPI 
Join09 MattTLB 
Join10 DamianAPI,ASM 
Join11 PaulAPI,ASM 
Join12 EgbertTLB 
Join13 PaulTLB 
Call 1
   
10100.734,811Ás
850.232,399Ás
76.24298Ás
42.25108Ás
62.41115Ás
52.36113Ás
9100.374,794Ás
31.3062Ás
11.0048Ás
X0.9847Ás
X0.4421Ás
21.0952Ás
X1.3966Ás
Call 2
   
1096.755,514Ás
848.002,736Ás
79.62548Ás
64.48255Ás
52.77158Ás
42.69153Ás
996.595,504Ás
32.14122Ás
11.0057Ás
X0.9655Ás
X0.4827Ás
21.78101Ás
X1.3175Ás
Call 3
   
914.2974.470Ás
89.8451.314Ás
79.0747.274Ás
64.1821.813Ás
42.8214.718Ás
52.8314.750Ás
1014.5575.835Ás
32.1611.275Ás
11.005.212Ás
X0.965.021Ás
X0.442.272Ás
21.919.937Ás
X1.316.837Ás
Call 4
   
1043.49506Ás
722.33260Ás
827.57321Ás
43.5441Ás
65.4463Ás
55.4363Ás
943.18502Ás
31.5618Ás
11.0012Ás
X1.0112Ás
X1.0712Ás
21.4317Ás
X1.3716Ás
 VB6
CodeAuthorDopingNotes
Join VB6  
Join01 [traditional]  
Join02 [trad., impr.]  
Join03 JodyAPI 
Join04 JodyAPI 
Join05 Guido  
Join06 Keith  
Join07 Microsoft  
Join08 MattAPI 
Join09 MattTLB 
Join10 DamianAPI,ASM 
Join11 PaulAPI,ASM 
Join12 EgbertTLB 
Join13 PaulTLB 
Call 1
41.4566Ás
10100.904,608Ás
953.812,458Ás
88.04367Ás
72.37108Ás
61.7680Ás
51.7078Ás
11101.194,621Ás
31.4365Ás
11.0046Ás
X1.0247Ás
X0.4923Ás
21.1552Ás
X1.4566Ás
Call 2
21.3074Ás
10100.275,657Ás
948.752,751Ás
810.37585Ás
73.93222Ás
62.52142Ás
52.43137Ás
11102.175,765Ás
42.30130Ás
11.0056Ás
X0.9654Ás
X0.4726Ás
31.78100Ás
X1.3073Ás
Call 3
21.286.526Ás
1017.4288.832Ás
912.4363.401Ás
811.1256.726Ás
74.2521.657Ás
52.5412.939Ás
62.5513.028Ás
1117.5989.723Ás
42.3712.076Ás
11.005.100Ás
X0.974.953Ás
X0.432.183Ás
31.949.911Ás
X1.316.693Ás
Call 4
21.1814Ás
1045.20539Ás
823.61282Ás
928.69342Ás
73.5342Ás
51.9023Ás
61.9223Ás
1145.64544Ás
41.6119Ás
11.0012Ás
X1.0112Ás
X1.0012Ás
31.4217Ás
X1.3817Ás
Conclusions
Joining strings can be done fast if you're of the adventurous kind...
29-Sep-2002: what a battlefield! Finally Join09 (submitted 2 years ago!) rises again and shines brightly under XP.
Note: Timings above are based on typelib-declared APIs: CopyMemory (Kernel32), ZeroMemory (Kernel32), SysAllocStringByteLen (OleAut32). The typelib has been provided by Matt Curland for his Join09.

ASM-doped code is no longer allowed (older submissions will remain listed however).
Mail your code! How to read all those numbers


The Code
Join01
added 15-Sep-2000
Doping: none
Public Function Join01(sArray() As String, Optional Delimiter As String = " ") As String
' by [traditional]
  Dim i As Long
  For i = LBound(sArray) To UBound(sArray) - 1
    Join01 = Join01 & sArray(i) & Delimiter
  Next
  Join01 = Join01 & sArray(UBound(sArray))
End Function
Author's comments:
Donald's comments:

top | charts


Join02
added 15-Sep-2000
Doping: none
Public Function Join02(sArray() As String, Optional Delimiter As String = " ") As String
' by [traditional, improved]
  Dim i As Long
  For i = LBound(sArray) To UBound(sArray) - 1
    ' add smaller parts first
    Join02 = Join02 & (sArray(i) & Delimiter)
  Next
  Join02 = Join02 & sArray(UBound(sArray))
End Function
Author's comments:
Donald's comments: merely adding the parentheses in line Join02 = Join02 & (sArray(i) & Delimiter) doubles speed!

top | charts


Join03
added 15-Sep-2000
Doping: API, wrapped in class (download the class, VB5-compatible, zipped, 1KB)
Public Function Join03(sArray() As String, Optional Delimiter As String = " ") As String
' by Jody Gelowitz, http://www.visual-statement.com/vb
  Dim r As New CAppendString
  Dim i As Long
  
  For i = LBound(sArray) To UBound(sArray) - 1
    r.AddToString sArray(i) & Delimiter
  Next
  r.AddToString sArray(UBound(sArray))

  Join03 = r.ReturnString

  Set r = Nothing

End Function
Needs this class:
' By: Jody Gelowitz
' http://www.visual-statement.com/vb

Option Explicit

Private lPosition As Long
Private strBigString As String
Private lenBBigString As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Friend Sub AddToString(strAdd As String)

'If the current position + length of string to add is greater
'than the length of the BigString, then increase the size of
'the BigString
    If lPosition + LenB(strAdd) > lenBBigString Then
      strBigString = strBigString & Space$(10000)
      lenBBigString = LenB(strBigString)
    End If
'Add strAdd to the BigString
    CopyMemory ByVal StrPtr(strBigString) + lPosition, ByVal StrPtr(strAdd), LenB(strAdd)
'Move the pointer to show where the end of the string is
    lPosition = lPosition + LenB(strAdd)

End Sub

Friend Property Get ReturnString() As String

'Trim off the blank characters and return the string
    strBigString = Left$(strBigString, lPosition \ 2) 'trim back to size
    ReturnString = strBigString
    
End Property
Author's comments:
Donald's comments:

top | charts


Join04
added 15-Sep-2000
Doping: API
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Public Function Join04(sArray() As String, Optional Delimiter As String = " ") As String ' by Jody Gelowitz, http://www.visual-statement.com/vb ' * rewritten as self-sufficient procedure by Donald (00.0915) Dim strBigString As String Dim lenBBigString As Long Dim lenBDelimiter As Long Dim lenBElement As Long Dim lPosition As Long Dim i As Long ' len of Delimiter to fast var lenBDelimiter = LenB(Delimiter) For i = LBound(sArray) To UBound(sArray) - 1 ' len of this element to fast var lenBElement = LenB(sArray(i)) ' If the current position + length of string(s) to add is greater ' than the length of the BigString, then increase the size of ' the BigString If lPosition + lenBElement + lenBDelimiter > lenBBigString Then strBigString = strBigString & Space$(10000) lenBBigString = LenB(strBigString) End If ' Add strAdd to the BigString CopyMemory ByVal StrPtr(strBigString) + lPosition, ByVal StrPtr(sArray(i)), lenBElement ' Add delimiter to the BigString If lenBDelimiter Then CopyMemory ByVal StrPtr(strBigString) + lPosition + lenBElement, ByVal StrPtr(Delimiter), lenBDelimiter End If ' Move the pointer to show where the end of the string is lPosition = lPosition + lenBElement + lenBDelimiter Next ' Trim off the blank characters, and add last element the old-fashioned way Join04 = Left$(strBigString, lPosition \ 2) & sArray(UBound(sArray)) End Function
Author's comments:
Donald's comments: Since the CopyMemory API should be present in any project concerned with speed, this solution can be considered a copy+paste-ready reasonably fast emulation of VB6's Join.

top | charts


Join05
submitted 18-Sep-2000 by Guido Beckmann  
Doping: none
Public Function Join05(sArray() As String, _
    Optional Delimiter As String = " ") As String

' by G.Beckmann   eMail: G.Beckmann@NikoCity.de
    
    Dim c&, iLen&, iCurPos&, nChars&, iLo&, iHi&, nEmptyStr&
    
    '/ Calculate the size of the new string
    iLo = LBound(sArray)
    iHi = UBound(sArray)
    For c = iHi To iLo Step -1
        nChars = Len(sArray(c))
        iLen = iLen + nChars
        If nChars = 0 Then nEmptyStr = nEmptyStr + 1 Else Exit For
    Next c
    For c = iLo To iHi - nEmptyStr - 1
        iLen = iLen + Len(sArray(c))
    Next c
    
    nChars = Len(Delimiter)
    iLen = iLen + (iHi - iLo) * nChars
    
    '/ Fill the new string
    If iLen Then
        Join05 = Space$(iLen)
        
        Mid$(Join05, 1) = sArray(iLo)
        iCurPos = Len(sArray(iLo)) + 1
        
        If nChars Then
            For c = iLo + 1 To iHi - nEmptyStr
                Mid$(Join05, iCurPos, nChars) = Delimiter
                iCurPos = iCurPos + nChars
            
                Mid$(Join05, iCurPos, iLen) = sArray(c)
                iCurPos = iCurPos + Len(sArray(c))
            Next c
            For c = iCurPos To iLen Step nChars
                Mid$(Join05, c, nChars) = Delimiter
            Next c
        Else
            For c = iLo + 1 To iHi - nEmptyStr
                Mid$(Join05, iCurPos, iLen) = sArray(c)
                iCurPos = iCurPos + Len(sArray(c))
            Next c
        End If
    End If

End Function
Author's comments:
Donald's comments: Clever code!

top | charts


Join06
submitted 25-Sep-2000 by Keith Matzen  
Doping: none
Public Function Join06(sArray() As String, _
                     Optional sDelimiter As String = " ") As String
 
   ' by G.Beckmann   eMail: G.Beckmann@NikoCity.de
   ' modified by Keith, kmatzen@ispchannel.com
    
   Dim lNdx      As Long
   Dim lJoinLen  As Long
   Dim lCurPos   As Long
   Dim lDelimLen As Long
   Dim lLo       As Long
   Dim lHi       As Long
   Dim lLastStr  As Long
   
   lLo = LBound(sArray)
   lHi = UBound(sArray)
   lDelimLen = Len(sDelimiter)
   
   '/ Calculate the size of the new string
   lJoinLen = (lHi - lLo) * lDelimLen
   For lNdx = lHi To lLo Step -1
      If Len(sArray(lNdx)) > 0 Then
         lJoinLen = lJoinLen + Len(sArray(lNdx))
         lLastStr = lNdx          'Position of last non-empty string
         Exit For
      End If
   Next lNdx
   For lNdx = lLo To lLastStr - 1
      lJoinLen = lJoinLen + Len(sArray(lNdx))
   Next lNdx
 
   '/ Fill the new string
   If lJoinLen > 0 Then
      Join06 = Space$(lJoinLen)
            
      Mid$(Join06, 1) = sArray(lLo)
      lCurPos = Len(sArray(lLo)) + 1
      If lDelimLen > 0 Then
         For lNdx = lLo + 1 To lLastStr
            Mid$(Join06, lCurPos, lDelimLen) = sDelimiter
            lCurPos = lCurPos + lDelimLen
            
            Mid$(Join06, lCurPos, lJoinLen) = sArray(lNdx)
            lCurPos = lCurPos + Len(sArray(lNdx))
         Next lNdx
         For lNdx = lCurPos To lJoinLen Step lDelimLen
            Mid$(Join06, lNdx, lDelimLen) = sDelimiter
         Next lNdx
      Else
         For lNdx = lLo + 1 To lLastStr
            Mid$(Join06, lCurPos, lJoinLen) = sArray(lNdx)
            lCurPos = lCurPos + Len(sArray(lNdx))
         Next lNdx
      End If
   End If
 
End Function
Author's comments: It's hard to make sense of anything anymore. Looking at the Join function, I made a number of changes that should have improved performance but it actually got slower. Many of the optimizations are apparently already being done by the compiler. That would explain why the performance improvement mainly appears in the IDE.
Donald's comments:

top | charts


Join07
added 25-Sep-2000, source: Microsoft
Doping: none
Public Function Join07(source() As String, Optional _
            sDelim As String = " ") As String
' by Microsoft, http://support.microsoft.com/support/kb/articles/q188/0/07.asp
      Dim sOut As String, iC As Integer
      On Error GoTo errh:
          For iC = LBound(source) To UBound(source) - 1
              sOut = sOut & source(iC) & sDelim
          Next
          sOut = sOut & source(iC)
          Join07 = sOut
          Exit Function
errh:
          Err.Raise Err.Number
End Function
Author's comments:
Donald's comments: Apart from the error-handling, there's no difference to Join01. I just feature this code to give Microsoft some, uh, motivation to try a little bit harder ...

top | charts


Join08
submitted 01-Oct-2000 by Matt Curland    PowerVB
Doping: API
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Declare Function SysAllocStringByteLen Lib "oleaut32.dll" _
    (ByVal lpstr As Long, ByVal ByteLen As Long) As Long


Public Function Join08(SourceArray() As String, _ Optional Delimiter As String = " ", _ Optional ByVal Count As Long = -1) As String ' by Matt Curland, mattcur@microsoft.com, www.PowerVB.com, 20001001 ' [org. name Join7, slight adjustments to our definition by Donald] ' Works with VB- or typelib-declared CopyMemory (pass strings with StrPtr) Dim Lower As Long Dim Upper As Long Dim cbDelim As Long Dim cbTotal As Long Dim i As Long Dim pCurDest As Long Dim pDelim As Long Dim cbCur As Long Lower = LBound(SourceArray) If Count = -1 Then Upper = UBound(SourceArray) Else Upper = Lower + Count - 1 End If For i = Lower To Upper cbTotal = cbTotal + LenB(SourceArray(i)) Next i cbDelim = LenB(Delimiter) If cbDelim Then cbTotal = cbTotal + cbDelim * (Upper - Lower) 'Use API to avoid useless initialization CopyMemory ByVal VarPtr(Join08), SysAllocStringByteLen(0, cbTotal), 4 'Use this instead if APIs are typelib-declared: ''Join08 = SysAllocStringByteLen(0, cbTotal) 'Now, split into two different paths 'a) No delimiter 'b) Delimiter pCurDest = StrPtr(Join08) If cbDelim = 0 Then For i = Lower To Upper cbCur = LenB(SourceArray(i)) CopyMemory ByVal pCurDest, ByVal StrPtr(SourceArray(i)), cbCur pCurDest = pCurDest + cbCur Next i Else pDelim = StrPtr(Delimiter) For i = Lower To Upper - 1 cbCur = LenB(SourceArray(i)) CopyMemory ByVal pCurDest, ByVal StrPtr(SourceArray(i)), cbCur pCurDest = pCurDest + cbCur CopyMemory ByVal pCurDest, ByVal pDelim, cbDelim pCurDest = pCurDest + cbDelim Next i CopyMemory ByVal pCurDest, ByVal StrPtr(SourceArray(i)), LenB(SourceArray(i)) End If End Function
Author's comments:
Donald's comments: Note that the function features an additional Count parameter

top | charts


Join09
submitted 04-Oct-2000 by Matt Curland    PowerVB
Doping: needs typelib JoinDecl.tlb and module ArrayOwnerIgnoreOnly.bas (download these files, VB5-compatible).
Private Type OwnedInteger
    Owner As ArrayOwner
    pSA() As Integer
End Type
Private m_DerefInteger As OwnedInteger


Public Function Join09(SourceArray() As String, _ Optional Delimiter As String = " ", _ Optional ByVal Count As Long = -1) As String ' by Matt Curland, mattcur@microsoft.com, www.PowerVB.com, 20001004 'Works with typelib-declared CopyMemory only (no StrPtr protection). '1-character delimiter optimized using techniques from: ' Advanced Visual Basic: Power Techniques for Everyday Programs (http://www.PowerVB.com) 'Does not use VBoost.UAdd for incrementing pointers (fastest routine). Dim Lower As Long Dim Upper As Long Dim cbDelim As Long Dim cbTotal As Long Dim i As Long Dim pCurDest As Long Dim pDelim As Long Dim cbCur As Long Dim iDelim As Integer ' project: #Const NOVBOOST = 1 #If NOVBOOST = 0 Then 'Call InitVBoost before timing to get accurate results. Needed for ArrayOwner If VBoost Is Nothing Then InitVBoost #End If Lower = LBound(SourceArray) If Count = -1 Then Upper = UBound(SourceArray) Else Upper = Lower + Count - 1 End If For i = Lower To Upper cbTotal = cbTotal + LenB(SourceArray(i)) Next i cbDelim = LenB(Delimiter) If cbDelim Then cbTotal = cbTotal + cbDelim * (Upper - Lower) 'Use API to avoid useless initialization Join09 = SysAllocStringByteLen(0, cbTotal) 'Now, split into three different paths 'a) No delimiter 'b) One character delimiter 'c) > One character delimiter pCurDest = StrPtr(Join09) Select Case cbDelim Case 0 For i = Lower To Upper cbCur = LenB(SourceArray(i)) CopyMemory ByVal pCurDest, ByVal SourceArray(i), cbCur pCurDest = pCurDest + cbCur 'VBoost.UAdd(pCurDest, cbCur) Next i Case 2 'Use numeric assignment instead of CopyMemory to 'move the delimiter around iDelim = AscW(Delimiter) With m_DerefInteger If .Owner.SA.cDims = 0 Then InitArrayOwner .Owner, LenB(.pSA(0)), 0 For i = Lower To Upper - 1 cbCur = LenB(SourceArray(i)) CopyMemory ByVal pCurDest, ByVal SourceArray(i), cbCur pCurDest = pCurDest + cbCur 'VBoost.UAdd(pCurDest, cbCur) .Owner.SA.pvData = pCurDest .pSA(0) = iDelim pCurDest = pCurDest + 2 'VBoost.UAdd(pCurDest, cbCur) Next i CopyMemory ByVal pCurDest, ByVal SourceArray(i), LenB(SourceArray(i)) End With Case Else pDelim = StrPtr(Delimiter) For i = Lower To Upper - 1 cbCur = LenB(SourceArray(i)) CopyMemory ByVal pCurDest, ByVal SourceArray(i), cbCur pCurDest = pCurDest + cbCur 'VBoost.UAdd(pCurDest, cbCur) CopyMemory ByVal pCurDest, ByVal pDelim, cbDelim pCurDest = pCurDest + cbDelim 'VBoost.UAdd(pCurDest, cbCur) Next i CopyMemory ByVal pCurDest, ByVal SourceArray(i), LenB(SourceArray(i)) End Select End Function
Author's comments:
Donald's comments: Note that the function features an additional Count parameter

top | charts


Join10
submitted 06-Oct-2000 by Damian  
Doping: API and ASM (Assembly Snippets), wrapped in class (download the class, VB5-compatible, zipped, 3KB)
The code is a bit too long to be displayed here ... download it to have a look.
Author's comments:
Donald's comments: Very fast even in the IDE!

top | charts


Join11
submitted 21-Sep-2001 by Paul  
Doping: API and ASM (Assembly Snippets), wrapped in class (download the class, VB5-compatible, zipped, 2KB)
The code is a bit too long to be displayed here ... download it to have a look.
Author's comments: A slightly optimized version of Join10 by Damian.
Donald's comments: Very, very fast -- even in the IDE!

top | charts


Join12
submitted 28-May-2002 by Egbert Nierop  
Doping: TLB (cf. Dope'n'Declarations)
Public Function Join12(SourceArray As Variant, _
              Optional Delimiter As Variant = " ") As String
    'made by Egbert Nierop at egbert_nierop.nospam@hotmail.com at april 2001, 20020528
    ' remove the spam prevention by robots to email

    ' win95 does not have NTDLL.DLL I think :< but if you have win95,
    '     install a decent windows please :)
    '     or just leave the idemode = True intact
    
    ' warning! Testing with this precompiled switch to False will
    ' crash the VB IDE
    ' in compiled mode however, vb compiles the __cdecl correct by
    '  ADD ESP, -12 whichs means decrement stack pointer by 12 (each pointer is 4 bytes)
    #Const idemode = True
    
    Dim lUbound As Long
    Dim lDelimLen As Long
    
    '  important. The compiled location from these two variables just differ 4 bytes
    ' because they are anyway on the stack
    ' this way I have no TYPE/ struct overhead
    '   so do not place any variables between them!

    Dim lElemLen As Long
    
    Dim lMaxLen As Long
    Dim lOldLen As Long
    Dim lLbound As Long
    Dim sTemp() As String
    
    Dim lTemp As Long
    Dim iVType As Integer
    Dim psaData As Long
    Dim sDelimiter As String
    Dim bFill As Boolean
    Const VT_BYREF = &H4000
    Dim psa As Long
    Dim sPtr As Long


    #If idemode = True Then

        kernel.MoveMemory iVType, SourceArray, 2
        kernel.MoveMemory SourceArray, vbLong, 2
        psa = SourceArray
        kernel.MoveMemory SourceArray, iVType, 2

    #Else

        ntdll.MoveMemory iVType, SourceArray, 2
        ntdll.MoveMemory SourceArray, vbLong, 2
        psa = SourceArray
        ntdll.MoveMemory SourceArray, iVType, 2

    #End If
    
    If iVType And (vbArray Or vbString) = 0 Then Exit Function
    
    ' reindex if the variant parameter was sent by reference
    ' one of the optimizations for oleaut :)
    If iVType And VT_BYREF Then
        #If idemode = True Then
            kernel.MoveMemory psa, ByVal psa, 4
        #Else
            ntdll.MoveMemory psa, ByVal psa, 4
        #End If
    End If
    'dont process non-initialised SafeArrays
    If psa = 0 Then Err.Raise 9

    #If idemode = True Then
        kernel.MoveMemory ByVal ArrayPtr.VarPtrStringArray(sTemp()), psa, 4
    #Else
        ntdll.MoveMemory ByVal ArrayPtr.VarPtrStringArray(sTemp()), psa, 4
    #End If
   
   ' If UBound(sTemp(), 1) <> 1 Then Err.Raise 9
    sDelimiter = Delimiter

    lLbound = OleAut.SafeArrayGetLBound(psa, 1)
    lUbound = OleAut.SafeArrayGetUBound(psa, 1)
    lDelimLen = OleAut.SysStringByteLen(sDelimiter)
    Dim x As Long

    For x = lLbound To lUbound
        lMaxLen = lMaxLen + OleAut.SysStringByteLen(sTemp(x)) + lDelimLen
    Next
    lMaxLen = lMaxLen - lDelimLen
    
    If lUbound - lLbound = 0 Then
        Err.Raise 9
    End If
    
   
    sPtr = OleAut.SysAllocStringByteLenPtr(ByVal 0&, lMaxLen)
    For lLbound = lLbound To lUbound
        lElemLen = OleAut.SysStringByteLen(sTemp(lLbound))
        
        #If idemode = True Then
            
            kernel.MoveMemoryFromStr ByVal sPtr + lOldLen, sTemp(lLbound), lElemLen
            lOldLen = lOldLen + lElemLen
            If lDelimLen Then
                kernel.MoveMemoryFromStr ByVal sPtr + lOldLen, sDelimiter, lDelimLen
                lOldLen = lOldLen + lDelimLen
            End If

        #Else 'compilemode

            ntdll.MoveMemoryFromStr ByVal sPtr + lOldLen, sTemp(lLbound), lElemLen
            lOldLen = lOldLen + lElemLen

            If lDelimLen Then
                ntdll.MoveMemoryFromStr ByVal sPtr + lOldLen, sDelimiter, lDelimLen
                lOldLen = lOldLen + lDelimLen
            End If

        #End If

    Next
    kernel.ZeroMemory ByVal ArrayPtr.VarPtrStringArray(sTemp()), 4
    
    #If idemode = True Then
        kernel.MoveMemory Join12, sPtr, Len(sPtr)
    #Else
        ntdll.MoveMemory Join12, sPtr, Len(sPtr)
    #End If

End Function
Author's comments:
Donald's comments: Timing was done with #Const idemode = True. Respect the IDE!

top | charts


Join13
submitted 10-Jun-2002 by Paul  
Doping: TLB (cf. Dope'n'Declarations)
  [29-Sep-2002] Note that the function returns incorrect results with delimiters that are longer than one character.
Class-wrapped. Cinemascope here, preview here:

Author's comments :
Donald's comments :

top | charts




VBspeed © 2000-10 by Donald Lessau