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
<!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 - strconv - String">
    <title>strconv - String - 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/string/index.html">String</a> / strconv</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">
            <p>VB6 StrConv Function
The <code>StrConv</code> function converts a string to a specified format.</p>
<h2 id="syntax">Syntax</h2>
<pre><code class="language-vbnet">StrConv(string, conversion[, LCID])</code></pre>
<h2 id="parameters">Parameters</h2>
<ul>
<li><code>string</code>: Required. String expression to be converted.</li>
<li><code>conversion</code>: Required. Integer specifying the type of conversion to perform. Can be one or more of the following constants (combined with <code>+</code> or <code>Or</code>):</li>
<li><code>vbUpperCase</code> (1): Converts the string to uppercase characters</li>
<li><code>vbLowerCase</code> (2): Converts the string to lowercase characters</li>
<li><code>vbProperCase</code> (3): Converts the first letter of every word to uppercase</li>
<li><code>vbWide</code> (4): Converts narrow (single-byte) characters to wide (double-byte) characters</li>
<li><code>vbNarrow</code> (8): Converts wide (double-byte) characters to narrow (single-byte) characters</li>
<li><code>vbKatakana</code> (16): Converts Hiragana characters to Katakana characters (Japanese)</li>
<li><code>vbHiragana</code> (32): Converts Katakana characters to Hiragana characters (Japanese)</li>
<li><code>vbUnicode</code> (64): Converts the string to Unicode using the default code page</li>
<li><code>vbFromUnicode</code> (128): Converts the string from Unicode to the default code page</li>
<li><code>LCID</code>: Optional. <code>LocaleID</code> value, if different from the system <code>LocaleID</code> value. Default is the system <code>LocaleID</code>.</li>
</ul>
<h2 id="returns">Returns</h2>
<p>Returns a <code>Variant</code> (String) containing the converted string, or a <code>Variant</code> (Byte array) when converting to/from Unicode.</p>
<h2 id="remarks">Remarks</h2>
<p>The <code>StrConv</code> function provides powerful string transformation capabilities:
- <strong>Case conversion</strong>: <code>vbUpperCase</code>, <code>vbLowerCase</code>, and <code>vbProperCase</code> for text normalization
- <strong>Proper case rules</strong>: <code>vbProperCase</code> capitalizes first letter after spaces and certain punctuation
- <strong>Wide/Narrow conversion</strong>: For Asian languages with double-byte character sets (DBCS)
- <strong>Japanese character conversion</strong>: <code>vbKatakana</code> and <code>vbHiragana</code> for Japanese text
- <strong>Unicode conversion</strong>: <code>vbUnicode</code> converts string to byte array, <code>vbFromUnicode</code> converts byte array to string
- <strong>Combining conversions</strong>: Can combine multiple conversions using <code>+</code> or <code>Or</code> (e.g., <code>vbUpperCase + vbWide</code>)
- <strong>Return type varies</strong>: String conversions return String, Unicode conversions return Byte array
- <strong>Locale-aware</strong>: Proper case conversion respects locale settings
- <strong>Performance</strong>: Efficient for bulk text transformation</p>
<h3 id="case-conversion-details">Case Conversion Details</h3>
<ul>
<li><code>vbUpperCase</code>: Converts all characters to uppercase using locale rules</li>
<li><code>vbLowerCase</code>: Converts all characters to lowercase using locale rules</li>
<li><code>vbProperCase</code>: Capitalizes first letter of each word, converts rest to lowercase</li>
<li>Words are delimited by spaces, tabs, and some punctuation</li>
<li>Preserves existing spacing and punctuation</li>
</ul>
<h3 id="unicode-conversion-details">Unicode Conversion Details</h3>
<ul>
<li><code>vbUnicode</code>: Converts String to Byte array containing Unicode (UTF-16LE) representation</li>
<li>Each character becomes 2 bytes</li>
<li>Useful for binary file operations or API calls</li>
<li><code>vbFromUnicode</code>: Converts Byte array back to String</li>
<li>Expects byte array in Unicode format</li>
<li>Reverses <code>vbUnicode</code> conversion</li>
</ul>
<h3 id="widenarrow-conversion-dbcs">Wide/Narrow Conversion (DBCS)</h3>
<ul>
<li>Relevant for Asian languages (Japanese, Chinese, Korean)</li>
<li>Wide characters occupy two bytes, narrow characters occupy one byte</li>
<li><code>vbWide</code>: Converts half-width to full-width characters</li>
<li><code>vbNarrow</code>: Converts full-width to half-width characters</li>
</ul>
<h2 id="typical-uses">Typical Uses</h2>
<ol>
<li><strong>Text Normalization</strong>: Convert user input to consistent case for comparisons</li>
<li><strong>Title Formatting</strong>: Format text in proper case for titles and headings</li>
<li><strong>Data Validation</strong>: Normalize strings before validation or storage</li>
<li><strong>Case-Insensitive Operations</strong>: Convert to uppercase/lowercase for comparisons</li>
<li><strong>Unicode File I/O</strong>: Convert strings to/from Unicode byte arrays for file operations</li>
<li><strong>API Calls</strong>: Convert strings to Unicode byte arrays for Win32 API calls</li>
<li><strong>Japanese Text Processing</strong>: Convert between Hiragana and Katakana</li>
<li><strong>Database Storage</strong>: Normalize case before storing in databases</li>
</ol>
<h2 id="basic-examples">Basic Examples</h2>
<h3 id="example-1-case-conversion">Example 1: Case Conversion</h3>
<pre><code class="language-vbnet">Dim text As String
Dim result As String
text = &quot;Hello World&quot;
result = StrConv(text, vbUpperCase)    &#x27; &quot;HELLO WORLD&quot;
result = StrConv(text, vbLowerCase)    &#x27; &quot;hello world&quot;
result = StrConv(text, vbProperCase)   &#x27; &quot;Hello World&quot;
text = &quot;the quick brown fox&quot;
result = StrConv(text, vbProperCase)   &#x27; &quot;The Quick Brown Fox&quot;</code></pre>
<h3 id="example-2-unicode-conversion">Example 2: Unicode Conversion</h3>
<pre><code class="language-vbnet">Dim text As String
Dim bytes() As Byte
Dim restored As String
text = &quot;Hello&quot;
&#x27; Convert to Unicode byte array
bytes = StrConv(text, vbUnicode)
&#x27; bytes contains: 72, 0, 101, 0, 108, 0, 108, 0, 111, 0
&#x27; Convert back to string
restored = StrConv(bytes, vbFromUnicode)  &#x27; &quot;Hello&quot;</code></pre>
<h3 id="example-3-combining-conversions">Example 3: Combining Conversions</h3>
<pre><code class="language-vbnet">Dim text As String
Dim result As String
text = &quot;hello&quot;
&#x27; Combine uppercase with wide conversion (for DBCS)
result = StrConv(text, vbUpperCase + vbWide)</code></pre>
<h3 id="example-4-proper-case-formatting">Example 4: Proper Case Formatting</h3>
<pre><code class="language-vbnet">Dim name As String
Dim formatted As String
name = &quot;JOHN Q. PUBLIC&quot;
formatted = StrConv(name, vbProperCase)  &#x27; &quot;John Q. Public&quot;
name = &quot;o&#x27;brien&quot;
formatted = StrConv(name, vbProperCase)  &#x27; &quot;O&#x27;brien&quot;
&#x27; Note: StrConv doesn&#x27;t handle special cases like O&#x27;Brien</code></pre>
<h2 id="common-patterns">Common Patterns</h2>
<h3 id="pattern-1-normalize-user-input">Pattern 1: Normalize User Input</h3>
<pre><code class="language-vbnet">Function NormalizeInput(userInput As String) As String
    &#x27; Convert to uppercase for case-insensitive processing
    NormalizeInput = StrConv(Trim$(userInput), vbUpperCase)
End Function</code></pre>
<h3 id="pattern-2-format-name-properly">Pattern 2: Format Name Properly</h3>
<pre><code class="language-vbnet">Function FormatName(name As String) As String
    &#x27; Convert to proper case for display
    FormatName = StrConv(Trim$(name), vbProperCase)
End Function</code></pre>
<h3 id="pattern-3-case-insensitive-comparison">Pattern 3: Case-Insensitive Comparison</h3>
<pre><code class="language-vbnet">Function EqualsIgnoreCase(str1 As String, str2 As String) As Boolean
    EqualsIgnoreCase = (StrConv(str1, vbUpperCase) = StrConv(str2, vbUpperCase))
End Function</code></pre>
<h3 id="pattern-4-write-unicode-file">Pattern 4: Write Unicode File</h3>
<pre><code class="language-vbnet">Sub WriteUnicodeFile(filename As String, text As String)
    Dim fileNum As Integer
    Dim bytes() As Byte
    bytes = StrConv(text, vbUnicode)
    fileNum = FreeFile
    Open filename For Binary As #fileNum
    Put #fileNum, , bytes
    Close #fileNum
End Sub</code></pre>
<h3 id="pattern-5-read-unicode-file">Pattern 5: Read Unicode File</h3>
<pre><code class="language-vbnet">Function ReadUnicodeFile(filename As String) As String
    Dim fileNum As Integer
    Dim bytes() As Byte
    Dim fileSize As Long
    fileNum = FreeFile
    Open filename For Binary As #fileNum
    fileSize = LOF(fileNum)
    ReDim bytes(0 To fileSize - 1)
    Get #fileNum, , bytes
    Close #fileNum
    ReadUnicodeFile = StrConv(bytes, vbFromUnicode)
End Function</code></pre>
<h3 id="pattern-6-convert-array-of-strings">Pattern 6: Convert Array of Strings</h3>
<pre><code class="language-vbnet">Sub ConvertArrayToUpperCase(arr() As String)
    Dim i As Integer
    For i = LBound(arr) To UBound(arr)
        arr(i) = StrConv(arr(i), vbUpperCase)
    Next i
End Sub</code></pre>
<h3 id="pattern-7-title-case-for-sentences">Pattern 7: Title Case for Sentences</h3>
<pre><code class="language-vbnet">Function FormatTitle(title As String) As String
    Dim result As String
    &#x27; Convert to proper case
    result = StrConv(title, vbProperCase)
    &#x27; Handle articles and prepositions (simplified)
    result = Replace(result, &quot; A &quot;, &quot; a &quot;)
    result = Replace(result, &quot; An &quot;, &quot; an &quot;)
    result = Replace(result, &quot; The &quot;, &quot; the &quot;)
    result = Replace(result, &quot; Of &quot;, &quot; of &quot;)
    result = Replace(result, &quot; In &quot;, &quot; in &quot;)
    FormatTitle = result
End Function</code></pre>
<h3 id="pattern-8-database-normalization">Pattern 8: Database Normalization</h3>
<pre><code class="language-vbnet">Function NormalizeForDatabase(value As String) As String
    &#x27; Trim and convert to uppercase for storage
    NormalizeForDatabase = StrConv(Trim$(value), vbUpperCase)
End Function</code></pre>
<h3 id="pattern-9-compare-with-wildcard">Pattern 9: Compare with Wildcard</h3>
<pre><code class="language-vbnet">Function MatchesPattern(text As String, pattern As String) As Boolean
    &#x27; Case-insensitive pattern matching
    MatchesPattern = (StrConv(text, vbUpperCase) Like StrConv(pattern, vbUpperCase))
End Function</code></pre>
<h3 id="pattern-10-extract-unicode-bytes">Pattern 10: Extract Unicode Bytes</h3>
<pre><code class="language-vbnet">Function GetUnicodeBytes(text As String) As String
    Dim bytes() As Byte
    Dim i As Integer
    Dim result As String
    bytes = StrConv(text, vbUnicode)
    result = &quot;&quot;
    For i = LBound(bytes) To UBound(bytes)
        result = result &amp; CStr(bytes(i)) &amp; &quot; &quot;
    Next i
    GetUnicodeBytes = Trim$(result)
End Function</code></pre>
<h2 id="advanced-usage">Advanced Usage</h2>
<h3 id="example-1-text-normalizer-class">Example 1: Text Normalizer Class</h3>
<pre><code class="language-vbnet">&#x27; Class: TextNormalizer
&#x27; Provides text normalization and conversion utilities
Option Explicit
Public Enum NormalizationMode
    UpperCase = 1
    LowerCase = 2
    ProperCase = 3
    NoChange = 0
End Enum
Private m_Mode As NormalizationMode
Private m_TrimSpaces As Boolean
Public Sub Initialize(mode As NormalizationMode, trimSpaces As Boolean)
    m_Mode = mode
    m_TrimSpaces = trimSpaces
End Sub
Public Function Normalize(text As String) As String
    Dim result As String
    result = text
    &#x27; Trim if requested
    If m_TrimSpaces Then
        result = Trim$(result)
    End If
    &#x27; Apply case conversion
    Select Case m_Mode
        Case UpperCase
            result = StrConv(result, vbUpperCase)
        Case LowerCase
            result = StrConv(result, vbLowerCase)
        Case ProperCase
            result = StrConv(result, vbProperCase)
    End Select
    Normalize = result
End Function
Public Function NormalizeArray(arr() As String) As String()
    Dim result() As String
    Dim i As Integer
    ReDim result(LBound(arr) To UBound(arr))
    For i = LBound(arr) To UBound(arr)
        result(i) = Normalize(arr(i))
    Next i
    NormalizeArray = result
End Function
Public Function NormalizeCollection(col As Collection) As Collection
    Dim result As New Collection
    Dim item As Variant
    For Each item In col
        result.Add Normalize(CStr(item))
    Next item
    Set NormalizeCollection = result
End Function</code></pre>
<h3 id="example-2-unicode-file-handler">Example 2: Unicode File Handler</h3>
<pre><code class="language-vbnet">&#x27; Class: UnicodeFileHandler
&#x27; Handles reading and writing Unicode text files
Option Explicit
Public Sub WriteFile(filename As String, text As String, Optional appendMode As Boolean = False)
    Dim fileNum As Integer
    Dim bytes() As Byte
    Dim existingBytes() As Byte
    Dim existingSize As Long
    Dim newSize As Long
    bytes = StrConv(text, vbUnicode)
    fileNum = FreeFile
    If appendMode And Dir(filename) &lt;&gt; &quot;&quot; Then
        &#x27; Read existing content
        Open filename For Binary As #fileNum
        existingSize = LOF(fileNum)
        If existingSize &gt; 0 Then
            ReDim existingBytes(0 To existingSize - 1)
            Get #fileNum, , existingBytes
        End If
        Close #fileNum
        &#x27; Combine existing and new bytes
        newSize = existingSize + UBound(bytes) + 1
        ReDim Preserve existingBytes(0 To newSize - 1)
        Dim i As Long
        For i = 0 To UBound(bytes)
            existingBytes(existingSize + i) = bytes(i)
        Next i
        bytes = existingBytes
    End If
    &#x27; Write to file
    Open filename For Binary As #fileNum
    Put #fileNum, , bytes
    Close #fileNum
End Sub
Public Function ReadFile(filename As String) As String
    Dim fileNum As Integer
    Dim bytes() As Byte
    Dim fileSize As Long
    If Dir(filename) = &quot;&quot; Then
        Err.Raise 53, , &quot;File not found&quot;
    End If
    fileNum = FreeFile
    Open filename For Binary As #fileNum
    fileSize = LOF(fileNum)
    If fileSize = 0 Then
        Close #fileNum
        ReadFile = &quot;&quot;
        Exit Function
    End If
    ReDim bytes(0 To fileSize - 1)
    Get #fileNum, , bytes
    Close #fileNum
    ReadFile = StrConv(bytes, vbFromUnicode)
End Function
Public Function ReadLines(filename As String) As String()
    Dim content As String
    Dim lines() As String
    content = ReadFile(filename)
    lines = Split(content, vbCrLf)
    ReadLines = lines
End Function
Public Sub WriteLines(filename As String, lines() As String)
    Dim content As String
    content = Join(lines, vbCrLf)
    WriteFile filename, content
End Sub</code></pre>
<h3 id="example-3-case-converter-module">Example 3: Case Converter Module</h3>
<pre><code class="language-vbnet">&#x27; Module: CaseConverter
&#x27; Utilities for case conversion and formatting
Option Explicit
Public Function ToUpper(text As String) As String
    ToUpper = StrConv(text, vbUpperCase)
End Function
Public Function ToLower(text As String) As String
    ToLower = StrConv(text, vbLowerCase)
End Function
Public Function ToProper(text As String) As String
    ToProper = StrConv(text, vbProperCase)
End Function
Public Function ToTitleCase(text As String) As String
    &#x27; More sophisticated title case
    Dim result As String
    Dim words() As String
    Dim i As Integer
    Dim lowercaseWords As String
    &#x27; Start with proper case
    result = StrConv(text, vbProperCase)
    &#x27; Lowercase certain words (not first word)
    lowercaseWords = &quot; a an the and but or for nor of in on at to from by &quot;
    words = Split(result, &quot; &quot;)
    For i = 1 To UBound(words)  &#x27; Start at 1 to skip first word
        If InStr(lowercaseWords, &quot; &quot; &amp; LCase$(words(i)) &amp; &quot; &quot;) &gt; 0 Then
            words(i) = LCase$(words(i))
        End If
    Next i
    ToTitleCase = Join(words, &quot; &quot;)
End Function
Public Function ToggleCase(text As String) As String
    &#x27; Toggle case of each character
    Dim i As Integer
    Dim char As String
    Dim result As String
    result = &quot;&quot;
    For i = 1 To Len(text)
        char = Mid$(text, i, 1)
        If char = UCase$(char) Then
            result = result &amp; LCase$(char)
        Else
            result = result &amp; UCase$(char)
        End If
    Next i
    ToggleCase = result
End Function
Public Function IsAllUpper(text As String) As Boolean
    IsAllUpper = (text = StrConv(text, vbUpperCase))
End Function
Public Function IsAllLower(text As String) As Boolean
    IsAllLower = (text = StrConv(text, vbLowerCase))
End Function
Public Function IsProperCase(text As String) As Boolean
    IsProperCase = (text = StrConv(text, vbProperCase))
End Function</code></pre>
<h3 id="example-4-string-comparison-helper">Example 4: String Comparison Helper</h3>
<pre><code class="language-vbnet">&#x27; Module: StringComparisonHelper
&#x27; Case-insensitive comparison utilities
Option Explicit
Public Function EqualsIgnoreCase(str1 As String, str2 As String) As Boolean
    EqualsIgnoreCase = (StrConv(str1, vbUpperCase) = StrConv(str2, vbUpperCase))
End Function
Public Function StartsWithIgnoreCase(text As String, prefix As String) As Boolean
    Dim textUpper As String
    Dim prefixUpper As String
    textUpper = StrConv(text, vbUpperCase)
    prefixUpper = StrConv(prefix, vbUpperCase)
    StartsWithIgnoreCase = (Left$(textUpper, Len(prefixUpper)) = prefixUpper)
End Function
Public Function EndsWithIgnoreCase(text As String, suffix As String) As Boolean
    Dim textUpper As String
    Dim suffixUpper As String
    textUpper = StrConv(text, vbUpperCase)
    suffixUpper = StrConv(suffix, vbUpperCase)
    EndsWithIgnoreCase = (Right$(textUpper, Len(suffixUpper)) = suffixUpper)
End Function
Public Function ContainsIgnoreCase(text As String, searchValue As String) As Boolean
    Dim textUpper As String
    Dim searchUpper As String
    textUpper = StrConv(text, vbUpperCase)
    searchUpper = StrConv(searchValue, vbUpperCase)
    ContainsIgnoreCase = (InStr(textUpper, searchUpper) &gt; 0)
End Function
Public Function IndexOfIgnoreCase(text As String, searchValue As String) As Long
    Dim textUpper As String
    Dim searchUpper As String
    textUpper = StrConv(text, vbUpperCase)
    searchUpper = StrConv(searchValue, vbUpperCase)
    IndexOfIgnoreCase = InStr(textUpper, searchUpper)
End Function
Public Function ReplaceIgnoreCase(text As String, findText As String, _
                                  replaceText As String) As String
    Dim result As String
    Dim pos As Long
    Dim lastPos As Long
    Dim textUpper As String
    Dim findUpper As String
    result = &quot;&quot;
    lastPos = 1
    textUpper = StrConv(text, vbUpperCase)
    findUpper = StrConv(findText, vbUpperCase)
    pos = InStr(lastPos, textUpper, findUpper)
    Do While pos &gt; 0
        result = result &amp; Mid$(text, lastPos, pos - lastPos) &amp; replaceText
        lastPos = pos + Len(findText)
        pos = InStr(lastPos, textUpper, findUpper)
    Loop
    result = result &amp; Mid$(text, lastPos)
    ReplaceIgnoreCase = result
End Function</code></pre>
<h2 id="error-handling">Error Handling</h2>
<p>The <code>StrConv</code> function can raise the following errors:
- <strong>Error 5 (Invalid procedure call or argument)</strong>: If <code>conversion</code> constant is invalid or incompatible combinations are used
- <strong>Error 13 (Type mismatch)</strong>: If <code>string</code> argument cannot be converted to a string
- <strong>Error 6 (Overflow)</strong>: In rare cases with very large strings or byte arrays</p>
<h2 id="performance-notes">Performance Notes</h2>
<ul>
<li>Very fast for case conversions (uppercase, lowercase, proper case)</li>
<li>Unicode conversions are efficient but create byte arrays (memory overhead)</li>
<li>Proper case conversion slower than upper/lower case (more complex rules)</li>
<li>Wide/Narrow conversions only relevant for DBCS environments</li>
<li>Consider caching converted values if used repeatedly</li>
<li>For simple uppercase/lowercase, <code>UCase$</code> and <code>LCase$</code> may be slightly faster</li>
</ul>
<h2 id="best-practices">Best Practices</h2>
<ol>
<li><strong>Use for normalization</strong> before comparisons or storage</li>
<li><strong>Combine with Trim$</strong> to remove leading/trailing spaces before conversion</li>
<li><strong>Handle proper case limitations</strong> - doesn't handle special cases like "O'Brien" or "<code>McDonald</code>"</li>
<li><strong>Cache conversion constants</strong> in variables for clarity (e.g., <code>Const UPPER_CASE = vbUpperCase</code>)</li>
<li><strong>Use Unicode conversion</strong> for binary file I/O or API calls requiring Unicode</li>
<li><strong>Test with locale-specific text</strong> when using proper case or locale-dependent conversions</li>
<li><strong>Document conversion type</strong> in comments when not obvious from context</li>
<li><strong>Consider alternatives</strong> - <code>UCase$</code>, <code>LCase$</code> for simple case conversion (slightly faster)</li>
<li><strong>Validate conversion parameter</strong> when accepting user input</li>
<li><strong>Handle byte array return</strong> appropriately when using <code>vbUnicode</code> conversion</li>
</ol>
<h2 id="comparison-table">Comparison Table</h2>
<table>
<thead>
<tr>
<th>Function</th>
<th>Purpose</th>
<th>Returns</th>
<th>Locale-Aware</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>StrConv</code></td>
<td>Multiple conversions</td>
<td>String or Byte array</td>
<td>Yes</td>
</tr>
<tr>
<td><code>UCase$</code></td>
<td>Uppercase only</td>
<td>String</td>
<td>Yes</td>
</tr>
<tr>
<td><code>LCase$</code></td>
<td>Lowercase only</td>
<td>String</td>
<td>Yes</td>
</tr>
<tr>
<td><code>Format$</code></td>
<td>General formatting</td>
<td>String</td>
<td>Yes</td>
</tr>
</tbody>
</table>
<h2 id="platform-notes">Platform Notes</h2>
<ul>
<li>Available in VB6 and VBA</li>
<li>Not available in <code>VBScript</code></li>
<li><code>vbWide</code>/<code>vbNarrow</code> primarily for Asian language environments</li>
<li><code>vbKatakana</code>/<code>vbHiragana</code> only meaningful for Japanese text</li>
<li>Unicode conversion uses UTF-16LE (Windows default)</li>
<li>Proper case rules may vary by locale</li>
<li>LCID parameter rarely used (defaults to system locale)</li>
</ul>
<h2 id="limitations">Limitations</h2>
<ul>
<li>Proper case doesn't handle special cases (O'Brien, <code>McDonald</code>, etc.)</li>
<li>Cannot specify custom word delimiters for proper case</li>
<li>Unicode conversion always uses UTF-16LE (cannot specify encoding)</li>
<li>No direct support for other Unicode formats (UTF-8, UTF-32)</li>
<li>Wide/Narrow conversion limited to DBCS environments</li>
<li>Cannot combine incompatible conversions (e.g., <code>vbUpperCase + vbLowerCase</code>)</li>
<li>No validation of byte array format when using <code>vbFromUnicode</code></li>
<li>LCID parameter has limited practical use</li>
</ul>
        </article>
        
        <div style="margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-color);">
            <p>
                <a href="index.html">← Back to String</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>