Public Function IsGoodJoin() As Boolean
' verify correct Join returns, 20020929
' returns True if all tests are passed
' replace ".join13" with the name of your function to test
Dim fFailed As Boolean
Dim sArr(4) As String
sArr(0) = ""
sArr(1) = "a"
sArr(2) = ""
sArr(3) = "bc"
'With New CJoin
'With New CJoin2
With New CReplicationPaul
' 1-char delim
If .Join13(sArr(), ",") <> ",a,,bc," Then Stop: fFailed = True
sArr(4) = "d"
' 0-char delim
If .Join13(sArr(), "") <> "abcd" Then Stop: fFailed = True
' 2-char delim
If .Join13(sArr(), "12") <> "12a1212bc12d" Then Stop: fFailed = True
' missing delim
If .Join13(sArr()) <> " a bc d" Then Stop: fFailed = True
' alignment
sArr(0) = "123456789"
sArr(1) = "12345678"
sArr(2) = "1234567"
sArr(3) = "123456"
sArr(4) = "12345"
If .Join13(sArr(), ",") <> "123456789,12345678,1234567,123456,12345" Then Stop: fFailed = True
' handling unbound array
' VB6 Join returns "", but raising error 9 is ok
On Error Resume Next
Dim sArrUnbound() As String
If .Join13(sArrUnbound(), ",") <> "" Then
If Err.Number <> 9 Then
Stop: fFailed = True
End If
End If
On Error GoTo 0
' handling multi-dimensional array
' VB6 Join raises error 5, but raising error 9 is ok, too
On Error Resume Next
Dim sArr2(0, 0) As String
If .Join13(sArr2(), ",") <> "" Then
If Err.Number <> 5 And Err.Number <> 9 Then
Stop: fFailed = True
End If
End If
On Error GoTo 0
End With
' well done
IsGoodJoin = Not fFailed
End Function
Back to Join