vb6parse 1.0.0

vb6parse is a library for parsing and analyzing VB6 code, from projects, to controls, to modules, and forms.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="VB6Parse Library Reference - join - Arrays">
    <title>join - Arrays - VB6Parse Library Reference</title>
    <link rel="stylesheet" href="../../../assets/css/style.css">
    <link rel="stylesheet" href="../../../assets/css/docs-style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
    <script src="../../../assets/js/theme-switcher.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/vbnet.min.js"></script>
    <script>hljs.highlightAll();</script>
</head>
<body>
    <header class="docs-header">
        <div class="container">
            <h1><a href="../../../index.html">VB6Parse</a> / <a href="../../../library/index.html">Library</a> / <a href="../../../library/functions/arrays/index.html">Arrays</a> / join</h1>
            <p class="tagline">VB6 Library Reference</p>
        </div>
    </header>

    <nav class="docs-nav">
        <div class="container">
            <a href="../../../index.html">Home</a>
            <a href="../../../library/index.html">Library Reference</a>
            <a href="../../../documentation.html">Documentation</a>
            <a href="https://docs.rs/vb6parse" target="_blank">API Docs</a>
            <a href="https://github.com/scriptandcompile/vb6parse" target="_blank">GitHub</a>
            <button id="theme-toggle" class="theme-toggle" aria-label="Toggle theme">
                <span class="theme-icon">🌙</span>
            </button>
        </div>
    </nav>

    <main class="container">
        
        <article class="library-item">
            <h2 id="join-function">Join Function</h2>
<p>Returns a string created by joining a number of substrings contained in an array.</p>
<h2 id="syntax">Syntax</h2>
<pre><code class="language-text">Join(sourcearray, [delimiter])</code></pre>
<h2 id="parameters">Parameters</h2>
<ul>
<li><strong>sourcearray</strong> (Required): One-dimensional array containing substrings to be joined</li>
<li><strong>delimiter</strong> (Optional): <code>String</code> used to separate the substrings in the returned string</li>
<li>If omitted, space character (" ") is used</li>
<li>If empty string (""), items are concatenated with no separator</li>
</ul>
<h2 id="return-value">Return Value</h2>
<p>Returns a <code>String</code>
- <code>String</code> containing all elements of the array joined by the delimiter
- <code>Empty</code> string ("") if array has zero length
- Returns <code>Null</code> if <code>sourcearray</code> is <code>Null</code>
- Each array element is converted to <code>String</code> before joining
- Non-string elements are automatically converted using <code>Str</code>/<code>CStr</code>
- <code>Empty</code> array elements become empty strings in result
- Trailing / leading spaces in delimiter are preserved</p>
<h2 id="remarks">Remarks</h2>
<p>The <code>Join</code> function is the inverse of the <code>Split</code> function:
- Combines array elements into a single string
- Only works with one-dimensional arrays
- Array elements are converted to strings automatically
- Default delimiter is a space (" ")
- <code>Empty</code> string delimiter concatenates without separators
- <code>Null</code> array returns <code>Null</code> (not an error)
- Empty array (zero length) returns empty string
- Preserves empty array elements as empty strings
- Very efficient for building strings from multiple parts
- Much faster than repeated string concatenation in loops
- Available in VB6 and VBA (added in VB6/Office 2000)
- Common in text processing and file generation
- Works with <code>Variant</code> arrays containing mixed types
- Does not add delimiter after last element</p>
<h3 id="common-errors">Common Errors</h3>
<ul>
<li><strong>Error 13</strong> (Type Mismatch): <code>sourcearray</code> is a multi-dimensional array.</li>
</ul>
<h2 id="performance-considerations">Performance Considerations</h2>
<ul>
<li><strong>Very Efficient</strong>: Join is much faster than repeated concatenation</li>
<li><strong>String Building</strong>: Use Join instead of concatenation in loops</li>
<li><strong>Memory Usage</strong>: Creates single string allocation for result</li>
<li><strong>Large Arrays</strong>: Handles large arrays efficiently</li>
</ul>
<h3 id="performance-comparison">Performance comparison:</h3>
<pre><code class="language-vbnet">&#x27; SLOW: Repeated concatenation
Dim result As String
For i = 0 To 999
    result = result &amp; arr(i) &amp; &quot;,&quot;
Next i
&#x27; FAST: Using Join
result = Join(arr, &quot;,&quot;)</code></pre>
<h2 id="typical-uses">Typical Uses</h2>
<ol>
<li><strong>CSV Generation</strong>: Create comma-separated value strings</li>
<li><strong>Path Building</strong>: Combine path components with backslashes</li>
<li><strong>SQL Generation</strong>: Build SQL queries from parts</li>
<li><strong>Text Formatting</strong>: Create formatted text from arrays</li>
<li><strong>File Output</strong>: Generate text file content</li>
<li><strong>URL Building</strong>: Construct URLs from components</li>
<li><strong>String Building</strong>: Efficient alternative to concatenation loops</li>
<li><strong>Report Generation</strong>: Format report lines from data arrays</li>
</ol>
<h2 id="limitations">Limitations</h2>
<ul>
<li>Cannot join multi-dimensional arrays (use loops to flatten first)</li>
<li>Returns <code>Null</code> for <code>Null</code> array (not empty <code>String</code>)</li>
<li>No built-in escaping for CSV (must implement manually)</li>
<li>Cannot skip empty elements automatically</li>
<li>No formatting options for numeric values</li>
<li>Delimiter is applied between all elements (no custom logic)</li>
</ul>
<h3 id="platform-and-version-notes">Platform and Version Notes</h3>
<ul>
<li>Added in VB6 and Office 2000 VBA</li>
<li>Not available in VB5 or earlier</li>
<li>Part of <code>VBA.Strings</code> module</li>
<li>Returns <code>String</code> type</li>
<li>Only works with one-dimensional arrays</li>
<li>Automatically converts array elements to <code>String</code></li>
</ul>
<h2 id="related-functions">Related Functions</h2>
<ul>
<li><code>Split</code>: Split string into array (inverse of <code>Join</code>)</li>
<li><code>Filter</code>: Filter array elements based on criteria</li>
<li><code>UBound</code>/<code>LBound</code>: Get array bounds</li>
<li><code>Array</code>: Create array from values</li>
<li><code>Replace</code>: Replace substrings in <code>String</code></li>
</ul>
<h2 id="examples">Examples</h2>
<h3 id="join-with-default-delimiter-space">Join With Default Delimiter (space)</h3>
<pre><code class="language-vbnet">Dim words(2) As String
words(0) = &quot;Hello&quot;
words(1) = &quot;Visual&quot;
words(2) = &quot;Basic&quot;
Debug.Print Join(words)              &#x27; &quot;Hello Visual Basic&quot;</code></pre>
<h3 id="join-with-custom-delimiter">Join With Custom Delimiter</h3>
<pre><code class="language-vbnet">&#x27; Example 2: Join with custom delimiter
Dim values(3) As String
values(0) = &quot;apple&quot;
values(1) = &quot;banana&quot;
values(2) = &quot;cherry&quot;
values(3) = &quot;date&quot;
Debug.Print Join(values, &quot;, &quot;)       &#x27; &quot;apple, banana, cherry, date&quot;
Debug.Print Join(values, &quot; | &quot;)      &#x27; &quot;apple | banana | cherry | date&quot;
Debug.Print Join(values, &quot;&quot;)         &#x27; &quot;applebananacherrydate&quot;</code></pre>
<h3 id="csv-generation">CSV Generation</h3>
<pre><code class="language-vbnet">Dim fields(2) As String
fields(0) = &quot;John Doe&quot;
fields(1) = &quot;Engineer&quot;
fields(2) = &quot;50000&quot;
Dim csvLine As String
csvLine = Join(fields, &quot;,&quot;)
Debug.Print csvLine                  &#x27; &quot;John Doe,Engineer,50000&quot;</code></pre>
<h3 id="working-with-split-and-join">Working with Split and Join</h3>
<pre><code class="language-vbnet">Dim original As String
Dim parts() As String
Dim rebuilt As String
original = &quot;one-two-three-four&quot;
parts = Split(original, &quot;-&quot;)
rebuilt = Join(parts, &quot; &quot;)
Debug.Print rebuilt                  &#x27; &quot;one two three four&quot;</code></pre>
<h2 id="common-patterns">Common Patterns</h2>
<h3 id="pattern-1-build-csv-row">Pattern 1: Build CSV Row</h3>
<pre><code class="language-vbnet">Function BuildCSVRow(fields As Variant) As String
    BuildCSVRow = Join(fields, &quot;,&quot;)
End Function</code></pre>
<h3 id="pattern-2-join-with-line-breaks">Pattern 2: Join With Line Breaks</h3>
<pre><code class="language-vbnet">Function JoinLines(lines As Variant) As String
    JoinLines = Join(lines, vbCrLf)
End Function</code></pre>
<h3 id="pattern-3-build-path-from-components">Pattern 3: Build Path From Components</h3>
<pre><code class="language-vbnet">Function BuildPath(ParamArray parts() As Variant) As String
    Dim arr() As String
    Dim i As Long
    ReDim arr(LBound(parts) To UBound(parts))
    For i = LBound(parts) To UBound(parts)
        arr(i) = CStr(parts(i))
    Next i
    BuildPath = Join(arr, &quot;\&quot;)
End Function</code></pre>
<h3 id="pattern-4-create-comma-separated-list">Pattern 4: Create Comma-Separated List</h3>
<pre><code class="language-vbnet">Function ToCommaSeparated(items As Variant) As String
    If IsArray(items) Then
        ToCommaSeparated = Join(items, &quot;, &quot;)
    Else
        ToCommaSeparated = CStr(items)
    End If
End Function</code></pre>
<h3 id="pattern-5-build-sql-in-clause">Pattern 5: Build SQL IN Clause</h3>
<pre><code class="language-vbnet">Function BuildInClause(values As Variant) As String
    Dim i As Long
    Dim quoted() As String
    If Not IsArray(values) Then Exit Function
    ReDim quoted(LBound(values) To UBound(values))
    For i = LBound(values) To UBound(values)
        quoted(i) = &quot;&#x27;&quot; &amp; Replace(CStr(values(i)), &quot;&#x27;&quot;, &quot;&#x27;&#x27;&quot;) &amp; &quot;&#x27;&quot;
    Next i
    BuildInClause = Join(quoted, &quot;, &quot;)
End Function</code></pre>
<h3 id="pattern-6-join-non-empty-values-only">Pattern 6: Join Non-Empty Values Only</h3>
<pre><code class="language-vbnet">Function JoinNonEmpty(arr As Variant, delimiter As String) As String
    Dim result As Collection
    Dim i As Long
    Dim temp() As String
    Dim count As Long
    If Not IsArray(arr) Then Exit Function
    Set result = New Collection
    For i = LBound(arr) To UBound(arr)
        If Len(arr(i)) &gt; 0 Then
            result.Add CStr(arr(i))
        End If
    Next i
    If result.Count = 0 Then
        JoinNonEmpty = &quot;&quot;
        Exit Function
    End If
    ReDim temp(0 To result.Count - 1)
    For i = 1 To result.Count
        temp(i - 1) = result(i)
    Next i
    JoinNonEmpty = Join(temp, delimiter)
End Function</code></pre>
<h3 id="pattern-7-format-array-for-display">Pattern 7: Format Array For Display</h3>
<pre><code class="language-vbnet">Function FormatArray(arr As Variant) As String
    If Not IsArray(arr) Then
        FormatArray = CStr(arr)
    Else
        FormatArray = &quot;[&quot; &amp; Join(arr, &quot;, &quot;) &amp; &quot;]&quot;
    End If
End Function</code></pre>
<h3 id="pattern-8-build-where-clause">Pattern 8: Build WHERE Clause</h3>
<pre><code class="language-vbnet">Function BuildWhereClause(conditions As Variant) As String
    If Not IsArray(conditions) Then Exit Function
    If UBound(conditions) &lt; LBound(conditions) Then
        BuildWhereClause = &quot;&quot;
    Else
        BuildWhereClause = Join(conditions, &quot; AND &quot;)
    End If
End Function</code></pre>
<h3 id="pattern-9-create-delimited-string-with-quotes">Pattern 9: Create Delimited String With Quotes</h3>
<pre><code class="language-vbnet">Function JoinQuoted(items As Variant, delimiter As String) As String
    Dim i As Long
    Dim quoted() As String
    If Not IsArray(items) Then Exit Function
    ReDim quoted(LBound(items) To UBound(items))
    For i = LBound(items) To UBound(items)
        quoted(i) = Chr(34) &amp; items(i) &amp; Chr(34)  &#x27; Chr(34) = &quot;
    Next i
    JoinQuoted = Join(quoted, delimiter)
End Function</code></pre>
<h3 id="pattern-10-reverse-of-split-for-round-trip">Pattern 10: Reverse of Split for Round-Trip</h3>
<pre><code class="language-vbnet">Function ReverseTransform(text As String) As String
    Dim parts() As String
    Dim i As Long
    parts = Split(text, &quot; &quot;)
    &#x27; Reverse array
    For i = LBound(parts) To (UBound(parts) - LBound(parts)) \ 2 + LBound(parts)
        Dim temp As String
        temp = parts(i)
        parts(i) = parts(UBound(parts) - (i - LBound(parts)))
        parts(UBound(parts) - (i - LBound(parts))) = temp
    Next i
    ReverseTransform = Join(parts, &quot; &quot;)
End Function</code></pre>
<h2 id="advanced-usage-examples">Advanced Usage Examples</h2>
<h3 id="example-1-csv-builder-with-proper-escaping">Example 1: CSV Builder with proper escaping</h3>
<pre><code class="language-vbnet">Public Class CSVBuilder
    Private m_rows As Collection
    Private Sub Class_Initialize()
        Set m_rows = New Collection
    End Sub
    Public Sub AddRow(ParamArray values() As Variant)
        Dim i As Long
        Dim fields() As String
        ReDim fields(LBound(values) To UBound(values))
        For i = LBound(values) To UBound(values)
            fields(i) = EscapeCSV(CStr(values(i)))
        Next i
        m_rows.Add Join(fields, &quot;,&quot;)
    End Sub
    Private Function EscapeCSV(value As String) As String
        If InStr(value, &quot;,&quot;) &gt; 0 Or InStr(value, Chr(34)) &gt; 0 Or _
           InStr(value, vbCrLf) &gt; 0 Then
            &#x27; Need to quote and escape
            EscapeCSV = Chr(34) &amp; Replace(value, Chr(34), Chr(34) &amp; Chr(34)) &amp; Chr(34)
        Else
            EscapeCSV = value
        End If
    End Function
    Public Function GetCSV() As String
        Dim i As Long
        Dim lines() As String
        If m_rows.Count = 0 Then
            GetCSV = &quot;&quot;
            Exit Function
        End If
        ReDim lines(0 To m_rows.Count - 1)
        For i = 1 To m_rows.Count
            lines(i - 1) = m_rows(i)
        Next i
        GetCSV = Join(lines, vbCrLf)
    End Function
    Public Sub Clear()
        Set m_rows = New Collection
    End Sub
End Class</code></pre>
<h3 id="example-2-string-builder-for-efficient-concatenation">Example 2: String Builder For Efficient Concatenation</h3>
<pre><code class="language-vbnet">Public Class StringBuilder
    Private m_parts As Collection
    Private m_delimiter As String
    Private Sub Class_Initialize()
        Set m_parts = New Collection
        m_delimiter = &quot;&quot;
    End Sub
    Public Property Let Delimiter(value As String)
        m_delimiter = value
    End Property
    Public Sub Append(text As String)
        m_parts.Add text
    End Sub
    Public Sub AppendLine(text As String)
        m_parts.Add text &amp; vbCrLf
    End Sub
    Public Function ToString() As String
        Dim i As Long
        Dim arr() As String
        If m_parts.Count = 0 Then
            ToString = &quot;&quot;
            Exit Function
        End If
        ReDim arr(0 To m_parts.Count - 1)
        For i = 1 To m_parts.Count
            arr(i - 1) = m_parts(i)
        Next i
        ToString = Join(arr, m_delimiter)
    End Function
    Public Sub Clear()
        Set m_parts = New Collection
    End Sub
    Public Function Length() As Long
        Length = Len(ToString())
    End Function
End Class</code></pre>
<h3 id="example-3-query-builder-using-join">Example 3: Query Builder Using Join</h3>
<pre><code class="language-vbnet">Public Class QueryBuilder
    Private m_select As Collection
    Private m_from As String
    Private m_where As Collection
    Private m_orderBy As Collection
    Private Sub Class_Initialize()
        Set m_select = New Collection
        Set m_where = New Collection
        Set m_orderBy = New Collection
    End Sub
    Public Sub AddField(fieldName As String)
        m_select.Add fieldName
    End Sub
    Public Sub SetTable(tableName As String)
        m_from = tableName
    End Sub
    Public Sub AddCondition(condition As String)
        m_where.Add condition
    End Sub
    Public Sub AddOrderBy(fieldName As String)
        m_orderBy.Add fieldName
    End Sub
    Public Function BuildSQL() As String
        Dim sql As String
        Dim fields() As String
        Dim conditions() As String
        Dim orderFields() As String
        Dim i As Long
        &#x27; SELECT clause
        If m_select.Count = 0 Then
            sql = &quot;SELECT *&quot;
        Else
            ReDim fields(0 To m_select.Count - 1)
            For i = 1 To m_select.Count
                fields(i - 1) = m_select(i)
            Next i
            sql = &quot;SELECT &quot; &amp; Join(fields, &quot;, &quot;)
        End If
        &#x27; FROM clause
        If m_from &lt;&gt; &quot;&quot; Then
            sql = sql &amp; &quot; FROM &quot; &amp; m_from
        End If
        &#x27; WHERE clause
        If m_where.Count &gt; 0 Then
            ReDim conditions(0 To m_where.Count - 1)
            For i = 1 To m_where.Count
                conditions(i - 1) = m_where(i)
            Next i
            sql = sql &amp; &quot; WHERE &quot; &amp; Join(conditions, &quot; AND &quot;)
        End If
        &#x27; ORDER BY clause
        If m_orderBy.Count &gt; 0 Then
            ReDim orderFields(0 To m_orderBy.Count - 1)
            For i = 1 To m_orderBy.Count
                orderFields(i - 1) = m_orderBy(i)
            Next i
            sql = sql &amp; &quot; ORDER BY &quot; &amp; Join(orderFields, &quot;, &quot;)
        End If
        BuildSQL = sql
    End Function
    Public Sub Clear()
        Set m_select = New Collection
        m_from = &quot;&quot;
        Set m_where = New Collection
        Set m_orderBy = New Collection
    End Sub
End Class</code></pre>
<h3 id="example-4-report-formatter">Example 4: Report Formatter</h3>
<pre><code class="language-vbnet">Public Class ReportFormatter
    Public Function FormatTable(data As Variant, headers As Variant, _
                                 Optional delimiter As String = &quot; | &quot;) As String
        Dim lines As Collection
        Dim i As Long, j As Long
        Dim row() As String
        Dim allLines() As String
        Set lines = New Collection
        &#x27; Add header
        If IsArray(headers) Then
            lines.Add Join(headers, delimiter)
            &#x27; Add separator
            ReDim row(LBound(headers) To UBound(headers))
            For j = LBound(headers) To UBound(headers)
                row(j) = String(Len(headers(j)), &quot;-&quot;)
            Next j
            lines.Add Join(row, delimiter)
        End If
        &#x27; Add data rows
        If IsArray(data) Then
            For i = LBound(data) To UBound(data)
                If IsArray(data(i)) Then
                    lines.Add Join(data(i), delimiter)
                Else
                    lines.Add CStr(data(i))
                End If
            Next i
        End If
        &#x27; Convert collection to array and join
        ReDim allLines(0 To lines.Count - 1)
        For i = 1 To lines.Count
            allLines(i - 1) = lines(i)
        Next i
        FormatTable = Join(allLines, vbCrLf)
    End Function
    Public Function FormatList(items As Variant, _
                               Optional prefix As String = &quot;- &quot;) As String
        Dim i As Long
        Dim lines() As String
        If Not IsArray(items) Then
            FormatList = prefix &amp; CStr(items)
            Exit Function
        End If
        ReDim lines(LBound(items) To UBound(items))
        For i = LBound(items) To UBound(items)
            lines(i) = prefix &amp; CStr(items(i))
        Next i
        FormatList = Join(lines, vbCrLf)
    End Function
End Class</code></pre>
<h2 id="error-handling">Error Handling</h2>
<p>Join handles several special cases:</p>
<h3 id="empty-array-returns-empty-string">Empty Array Returns Empty String</h3>
<pre><code class="language-vbnet">Dim emptyArr() As String
ReDim emptyArr(0 To -1)  &#x27; Zero-length array
Debug.Print Join(emptyArr, &quot;,&quot;)  &#x27; Returns &quot;&quot;</code></pre>
<h3 id="null-array-returns-null">Null Array Returns Null</h3>
<pre><code class="language-vbnet">Dim nullArr As Variant
nullArr = Null
Debug.Print IsNull(Join(nullArr, &quot;,&quot;))  &#x27; True</code></pre>
<h3 id="works-with-mixed-type-variant-arrays">Works With Mixed-Type Variant Arrays</h3>
<pre><code class="language-vbnet">Dim mixed(2) As Variant
mixed(0) = 123
mixed(1) = &quot;text&quot;
mixed(2) = True
Debug.Print Join(mixed, &quot;-&quot;)  &#x27; &quot;123-text-True&quot;</code></pre>
<h3 id="multi-dimensional-arrays-cause-type-mismatch-error">Multi-Dimensional Arrays Cause Type Mismatch Error</h3>
<pre><code class="language-vbnet">Dim multi(1, 1) As String
&#x27; Join(multi, &quot;,&quot;)  &#x27; Error 13: Type Mismatch</code></pre>
<h2 id="best-practices">Best Practices</h2>
<ol>
<li><strong>Use Join for String Building</strong>: Much faster than repeated concatenation</li>
<li><strong>CSV Generation</strong>: Properly escape values containing delimiters</li>
<li><strong>Empty Delimiter</strong>: Use "" to concatenate without separators</li>
<li><strong>Check Array</strong>: Verify array exists before calling <code>Join</code></li>
<li><strong>Null Handling</strong>: Be aware <code>Join</code> returns <code>Null</code> for <code>Null</code> arrays</li>
<li><strong>Line Breaks</strong>: Use <code>vbCrLf</code>, <code>vbLf</code>, or <code>vbCr</code> as delimiter for multi-line text</li>
<li><strong>Collection to String</strong>: Convert <code>Collection</code> to array first, then <code>Join</code></li>
<li><strong>Type Conversion</strong>: <code>Join</code> automatically converts non-string elements</li>
</ol>
<h2 id="comparison-with-related-functions">Comparison with Related Functions</h2>
<table>
<thead>
<tr>
<th>Function</th>
<th>Purpose</th>
<th>Input</th>
<th>Output</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Join</code></td>
<td>Combine array to string</td>
<td><code>Array</code></td>
<td><code>String</code></td>
</tr>
<tr>
<td><code>Split</code></td>
<td>Split string to array</td>
<td><code>String</code></td>
<td><code>Array</code></td>
</tr>
<tr>
<td><code>String</code> concatenation (&amp;)</td>
<td>Combine two strings</td>
<td><code>Strings</code></td>
<td><code>String</code></td>
</tr>
<tr>
<td><code>Filter</code></td>
<td>Filter array elements</td>
<td><code>Array</code></td>
<td><code>Array</code></td>
</tr>
<tr>
<td><code>UBound</code>/<code>LBound</code></td>
<td>Get array bounds</td>
<td><code>Array</code></td>
<td><code>Long</code></td>
</tr>
</tbody>
</table>
<h2 id="join-vs-string-concatenation">Join vs String Concatenation</h2>
<pre><code class="language-vbnet">Dim arr(2) As String
arr(0) = &quot;A&quot;
arr(1) = &quot;B&quot;
arr(2) = &quot;C&quot;
&#x27; Using Join (FAST)
result = Join(arr, &quot;,&quot;)              &#x27; &quot;A,B,C&quot;
&#x27; Using concatenation (SLOW)
result = arr(0) &amp; &quot;,&quot; &amp; arr(1) &amp; &quot;,&quot; &amp; arr(2)  &#x27; &quot;A,B,C&quot;
&#x27; For large arrays, Join is dramatically faster</code></pre>
<h2 id="join-and-split-round-trip">Join and Split Round-Trip</h2>
<pre><code class="language-vbnet">&#x27; Original string
original = &quot;apple,banana,cherry&quot;
&#x27; Split into array
parts = Split(original, &quot;,&quot;)         &#x27; [&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;]
&#x27; Join back to string
rebuilt = Join(parts, &quot;,&quot;)           &#x27; &quot;apple,banana,cherry&quot;
Debug.Print original = rebuilt       &#x27; True - perfect round-trip</code></pre>
        </article>
        
        <div style="margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-color);">
            <p>
                <a href="index.html">← Back to Arrays</a> |
                <a href="../index.html">View all functions</a>
            </p>
        </div>

    </main>

    <footer>
        <div class="container">
            <p>&copy; 2024-2026 VB6Parse Contributors. Licensed under the MIT License.</p>
        </div>
    </footer>
</body>
</html>