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
<!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 - lcase - String">
    <title>lcase - 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> / lcase</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">
            <h1 id="lcase-function">LCase Function</h1>
<p>Returns a <code>String</code> that has been converted to lowercase.</p>
<h2 id="syntax">Syntax</h2>
<pre><code class="language-vbnet">LCase(string)</code></pre>
<h2 id="parameters">Parameters</h2>
<ul>
<li><code>string</code> (Required): Any valid string expression</li>
<li>If string contains <code>Null</code>, <code>Null</code> is returned</li>
</ul>
<h2 id="return-value">Return Value</h2>
<p>Returns a <code>String</code>:
- Contains the same string with all uppercase letters converted to lowercase
- Lowercase letters and non-alphabetic characters are unchanged
- Returns <code>Null</code> if string argument is <code>Null</code>
- Empty string returns empty string
- Only affects A-Z characters (not accented characters in some locales)
- Numbers, punctuation, and symbols are unchanged
- Whitespace is preserved</p>
<h2 id="remarks">Remarks</h2>
<p>The <code>LCase</code> function converts uppercase letters to lowercase:
- Only affects uppercase letters A-Z
- All other characters remain unchanged
- Counterpart to <code>UCase</code> function (converts to uppercase)
- <code>Null</code> propagates through the function (<code>Null</code> input returns <code>Null</code>)
- Does not modify the original string (strings are immutable in VB6)
- Locale-aware in some versions (may affect accented characters)
- Common for case-insensitive string comparisons
- Useful for normalizing user input
- Works with string variables, literals, and expressions
- Can be combined with other string functions (<code>Trim</code>, <code>Replace</code>, etc.)
- Performance is generally fast for typical strings
- For single character, consider using <code>LCase$</code> for slightly better performance
- <code>LCase$</code> variant returns <code>String</code> type (not <code>Variant</code>)</p>
<h2 id="typical-uses">Typical Uses</h2>
<ol>
<li><strong>Case-Insensitive Comparison</strong>: Compare strings ignoring case</li>
<li><strong>User Input Normalization</strong>: Convert user input to consistent case</li>
<li><strong>File Path Comparison</strong>: Compare file paths case-insensitively (on Windows)</li>
<li><strong>Search Operations</strong>: Case-insensitive text searching</li>
<li><strong>Data Validation</strong>: Normalize data for validation</li>
<li><strong>Database Queries</strong>: Prepare strings for case-insensitive matching</li>
<li><strong>Email Addresses</strong>: Normalize email addresses to lowercase</li>
<li><strong>Configuration Keys</strong>: Standardize configuration key format</li>
</ol>
<h2 id="basic-usage-examples">Basic Usage Examples</h2>
<pre><code class="language-vbnet">&#x27; Example 1: Basic lowercase conversion
Dim result As String
result = LCase(&quot;HELLO&quot;)              &#x27; &quot;hello&quot;
result = LCase(&quot;Hello World&quot;)        &#x27; &quot;hello world&quot;
result = LCase(&quot;VB6 Programming&quot;)    &#x27; &quot;vb6 programming&quot;
&#x27; Example 2: Case-insensitive comparison
Dim input As String
input = &quot;Yes&quot;
If LCase(input) = &quot;yes&quot; Then
    MsgBox &quot;User answered yes&quot;
End If
&#x27; Example 3: Mixed case preservation
Dim text As String
text = &quot;Hello123WORLD&quot;
Debug.Print LCase(text)              &#x27; &quot;hello123world&quot; - numbers unchanged
&#x27; Example 4: Null handling
Dim value As Variant
value = Null
Debug.Print IsNull(LCase(value))     &#x27; True - Null propagates</code></pre>
<h2 id="common-patterns">Common Patterns</h2>
<pre><code class="language-vbnet">&#x27; Pattern 1: Case-insensitive string comparison
Function EqualsIgnoreCase(str1 As String, str2 As String) As Boolean
    EqualsIgnoreCase = (LCase(str1) = LCase(str2))
End Function
&#x27; Pattern 2: Case-insensitive contains check
Function ContainsIgnoreCase(text As String, searchFor As String) As Boolean
    ContainsIgnoreCase = (InStr(1, LCase(text), LCase(searchFor)) &gt; 0)
End Function
&#x27; Pattern 3: Normalize user input
Function NormalizeInput(userInput As String) As String
    NormalizeInput = LCase(Trim(userInput))
End Function
&#x27; Pattern 4: Validate yes/no input
Function IsYes(input As String) As Boolean
    Select Case LCase(Trim(input))
        Case &quot;yes&quot;, &quot;y&quot;, &quot;true&quot;, &quot;1&quot;
            IsYes = True
        Case Else
            IsYes = False
    End Select
End Function
&#x27; Pattern 5: Case-insensitive array search
Function FindInArray(arr As Variant, searchValue As String) As Long
    Dim i As Long
    Dim searchLower As String
    FindInArray = -1
    If Not IsArray(arr) Then Exit Function
    searchLower = LCase(searchValue)
    For i = LBound(arr) To UBound(arr)
        If LCase(arr(i)) = searchLower Then
            FindInArray = i
            Exit Function
        End If
    Next i
End Function
&#x27; Pattern 6: Extract lowercase letters only
Function GetLowercaseLetters(text As String) As String
    Dim i As Long
    Dim char As String
    Dim result As String
    result = &quot;&quot;
    For i = 1 To Len(text)
        char = Mid(text, i, 1)
        If char = LCase(char) And char &gt;= &quot;a&quot; And char &lt;= &quot;z&quot; Then
            result = result &amp; char
        End If
    Next i
    GetLowercaseLetters = result
End Function
&#x27; Pattern 7: Normalize email address
Function NormalizeEmail(email As String) As String
    NormalizeEmail = LCase(Trim(email))
End Function
&#x27; Pattern 8: Case-insensitive Replace
Function ReplaceIgnoreCase(text As String, findStr As String, _
                           replaceStr As String) As String
    Dim pos As Long
    Dim result As String
    Dim textLower As String
    Dim findLower As String
    result = text
    textLower = LCase(text)
    findLower = LCase(findStr)
    pos = InStr(1, textLower, findLower)
    Do While pos &gt; 0
        result = Left(result, pos - 1) &amp; replaceStr &amp; _
                 Mid(result, pos + Len(findStr))
        textLower = LCase(result)
        pos = InStr(pos + Len(replaceStr), textLower, findLower)
    Loop
    ReplaceIgnoreCase = result
End Function
&#x27; Pattern 9: Check if string is all lowercase
Function IsAllLowercase(text As String) As Boolean
    IsAllLowercase = (text = LCase(text))
End Function
&#x27; Pattern 10: Toggle case
Function ToggleCase(text As String) As String
    Dim i As Long
    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</code></pre>
<h2 id="advanced-usage-examples">Advanced Usage Examples</h2>
<pre><code class="language-vbnet">&#x27; Example 1: Case-insensitive dictionary/lookup
Public Class CaseInsensitiveDictionary
    Private m_dict As Object  &#x27; Scripting.Dictionary
    Private Sub Class_Initialize()
        Set m_dict = CreateObject(&quot;Scripting.Dictionary&quot;)
        m_dict.CompareMode = vbTextCompare  &#x27; Alternative to LCase
    End Sub
    Public Sub Add(key As String, value As Variant)
        Dim keyLower As String
        keyLower = LCase(key)
        If m_dict.Exists(keyLower) Then
            Err.Raise 457, &quot;CaseInsensitiveDictionary&quot;, &quot;Key already exists&quot;
        End If
        If IsObject(value) Then
            Set m_dict(keyLower) = value
        Else
            m_dict(keyLower) = value
        End If
    End Sub
    Public Function Get(key As String) As Variant
        Dim keyLower As String
        keyLower = LCase(key)
        If Not m_dict.Exists(keyLower) Then
            Err.Raise 5, &quot;CaseInsensitiveDictionary&quot;, &quot;Key not found&quot;
        End If
        If IsObject(m_dict(keyLower)) Then
            Set Get = m_dict(keyLower)
        Else
            Get = m_dict(keyLower)
        End If
    End Function
    Public Function Exists(key As String) As Boolean
        Exists = m_dict.Exists(LCase(key))
    End Function
    Public Sub Remove(key As String)
        m_dict.Remove LCase(key)
    End Sub
End Class
&#x27; Example 2: Text search with case-insensitive highlighting
Public Class TextHighlighter
    Public Function Highlight(text As String, searchTerm As String, _
                              highlightStart As String, _
                              highlightEnd As String) As String
        Dim result As String
        Dim pos As Long
        Dim lastPos As Long
        Dim textLower As String
        Dim searchLower As String
        If Len(searchTerm) = 0 Then
            Highlight = text
            Exit Function
        End If
        result = &quot;&quot;
        lastPos = 1
        textLower = LCase(text)
        searchLower = LCase(searchTerm)
        pos = InStr(lastPos, textLower, searchLower)
        Do While pos &gt; 0
            &#x27; Add text before match
            result = result &amp; Mid(text, lastPos, pos - lastPos)
            &#x27; Add highlighted match
            result = result &amp; highlightStart &amp; _
                     Mid(text, pos, Len(searchTerm)) &amp; highlightEnd
            lastPos = pos + Len(searchTerm)
            pos = InStr(lastPos, textLower, searchLower)
        Loop
        &#x27; Add remaining text
        result = result &amp; Mid(text, lastPos)
        Highlight = result
    End Function
End Class
&#x27; Example 3: String matcher with wildcards
Public Class WildcardMatcher
    Public Function Matches(text As String, pattern As String, _
                            Optional caseSensitive As Boolean = False) As Boolean
        Dim textToMatch As String
        Dim patternToMatch As String
        If caseSensitive Then
            textToMatch = text
            patternToMatch = pattern
        Else
            textToMatch = LCase(text)
            patternToMatch = LCase(pattern)
        End If
        Matches = MatchesInternal(textToMatch, patternToMatch)
    End Function
    Private Function MatchesInternal(text As String, pattern As String) As Boolean
        &#x27; Simple wildcard matching (* = any chars, ? = any single char)
        If pattern = &quot;*&quot; Then
            MatchesInternal = True
            Exit Function
        End If
        If Len(pattern) = 0 Then
            MatchesInternal = (Len(text) = 0)
            Exit Function
        End If
        If Left(pattern, 1) = &quot;*&quot; Then
            &#x27; Try matching rest of pattern at various positions
            Dim i As Long
            For i = 0 To Len(text)
                If MatchesInternal(Mid(text, i + 1), Mid(pattern, 2)) Then
                    MatchesInternal = True
                    Exit Function
                End If
            Next i
            MatchesInternal = False
        ElseIf Left(pattern, 1) = &quot;?&quot; Then
            If Len(text) &gt; 0 Then
                MatchesInternal = MatchesInternal(Mid(text, 2), Mid(pattern, 2))
            Else
                MatchesInternal = False
            End If
        Else
            If Len(text) &gt; 0 And Left(text, 1) = Left(pattern, 1) Then
                MatchesInternal = MatchesInternal(Mid(text, 2), Mid(pattern, 2))
            Else
                MatchesInternal = False
            End If
        End If
    End Function
End Class
&#x27; Example 4: Command parser with case-insensitive commands
Public Class CommandParser
    Private m_commands As Collection
    Private Sub Class_Initialize()
        Set m_commands = New Collection
    End Sub
    Public Sub RegisterCommand(commandName As String, handler As Object)
        m_commands.Add handler, LCase(commandName)
    End Sub
    Public Function Parse(input As String) As Boolean
        Dim parts() As String
        Dim command As String
        Dim handler As Object
        Parse = False
        input = Trim(input)
        If Len(input) = 0 Then Exit Function
        parts = Split(input, &quot; &quot;)
        If UBound(parts) &lt; 0 Then Exit Function
        command = LCase(parts(0))
        On Error Resume Next
        Set handler = m_commands(command)
        On Error GoTo 0
        If Not handler Is Nothing Then
            &#x27; Execute command handler
            &#x27; handler.Execute(parts)
            Parse = True
        End If
    End Function
    Public Function GetCommandList() As String
        Dim i As Long
        Dim result As String
        result = &quot;&quot;
        For i = 1 To m_commands.Count
            If i &gt; 1 Then result = result &amp; &quot;, &quot;
            &#x27; Note: Can&#x27;t easily get key from Collection
            &#x27; This is simplified example
        Next i
        GetCommandList = result
    End Function
End Class</code></pre>
<h2 id="error-handling">Error Handling</h2>
<p><code>LCase</code> handles special cases gracefully:</p>
<pre><code class="language-vbnet">&#x27; Empty string returns empty string
Debug.Print LCase(&quot;&quot;)                &#x27; &quot;&quot;
&#x27; Null propagates
Dim value As Variant
value = Null
Debug.Print IsNull(LCase(value))     &#x27; True
&#x27; Non-alphabetic characters unchanged
Debug.Print LCase(&quot;123!@#&quot;)          &#x27; &quot;123!@#&quot;
&#x27; Mixed content
Debug.Print LCase(&quot;ABC123xyz&quot;)       &#x27; &quot;abc123xyz&quot;
&#x27; Safe pattern with Null check
Function SafeLCase(value As Variant) As String
    If IsNull(value) Then
        SafeLCase = &quot;&quot;
    Else
        SafeLCase = LCase(value)
    End If
End Function</code></pre>
<h2 id="performance-considerations">Performance Considerations</h2>
<ul>
<li><strong>Fast Operation</strong>: <code>LCase</code> is generally very fast</li>
<li><strong>String Creation</strong>: Creates new string (strings are immutable)</li>
<li><strong>Repeated Calls</strong>: Cache result if using same lowercase value multiple times</li>
<li><strong><code>LCase$</code> Variant</strong>: Use <code>LCase$</code> for <code>String</code> return type (slightly faster)
Performance tips:</li>
</ul>
<pre><code class="language-vbnet">&#x27; Less efficient - multiple conversions
If LCase(str1) = LCase(str2) And LCase(str1) = LCase(str3) Then
&#x27; More efficient - cache conversion
Dim str1Lower As String
str1Lower = LCase(str1)
If str1Lower = LCase(str2) And str1Lower = LCase(str3) Then</code></pre>
<h2 id="best-practices">Best Practices</h2>
<ol>
<li><strong>Case-Insensitive Comparisons</strong>: Always use <code>LCase</code> for both operands</li>
<li><strong>Null Handling</strong>: Check for <code>Null</code> before calling <code>LCase</code> if needed</li>
<li><strong>Cache Results</strong>: Store converted strings when used multiple times</li>
<li><strong>Database Comparisons</strong>: Use <code>LCase</code> to normalize before database queries</li>
<li><strong>User Input</strong>: Always normalize user input with <code>LCase</code> + <code>Trim</code></li>
<li><strong>Email Addresses</strong>: Convert email addresses to lowercase for storage/comparison</li>
<li><strong>File Extensions</strong>: Use <code>LCase</code> when comparing file extensions</li>
<li><strong>Configuration</strong>: Use consistent casing for configuration keys</li>
</ol>
<h2 id="comparison-with-related-functions">Comparison with Related Functions</h2>
<table>
<thead>
<tr>
<th>Function</th>
<th>Purpose</th>
<th>Returns</th>
<th>Use Case</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>LCase</code></td>
<td>Convert to lowercase</td>
<td><code>String</code></td>
<td>Lowercase conversion</td>
</tr>
<tr>
<td><code>UCase</code></td>
<td>Convert to uppercase</td>
<td><code>String</code></td>
<td>Uppercase conversion</td>
</tr>
<tr>
<td><code>StrComp</code></td>
<td>Compare strings</td>
<td><code>Integer</code></td>
<td>Case-sensitive or insensitive comparison</td>
</tr>
<tr>
<td><code>Trim</code></td>
<td>Remove whitespace</td>
<td><code>String</code></td>
<td>Cleanup whitespace</td>
</tr>
<tr>
<td><code>Left</code>/<code>Right</code>/<code>Mid</code></td>
<td>Extract substring</td>
<td><code>String</code></td>
<td>Substring extraction</td>
</tr>
</tbody>
</table>
<h2 id="lcase-vs-strcomp"><code>LCase</code> vs <code>StrComp</code></h2>
<pre><code class="language-vbnet">Dim str1 As String, str2 As String
str1 = &quot;Hello&quot;
str2 = &quot;HELLO&quot;
&#x27; Using LCase for comparison
If LCase(str1) = LCase(str2) Then
    MsgBox &quot;Equal (case-insensitive)&quot;
End If
&#x27; Using StrComp for comparison
If StrComp(str1, str2, vbTextCompare) = 0 Then
    MsgBox &quot;Equal (case-insensitive)&quot;
End If
&#x27; LCase is more explicit and readable for simple comparisons
&#x27; StrComp is better when you need the comparison result (-1, 0, 1)</code></pre>
<h2 id="lcase-variant"><code>LCase$</code> Variant</h2>
<pre><code class="language-vbnet">&#x27; LCase returns Variant
Dim result As Variant
result = LCase(&quot;HELLO&quot;)
&#x27; LCase$ returns String (slightly faster, cannot handle Null)
Dim resultStr As String
resultStr = LCase$(&quot;HELLO&quot;)
&#x27; LCase$ will error on Null
&#x27; resultStr = LCase$(Null)  &#x27; Error 94: Invalid use of Null</code></pre>
<h2 id="platform-and-version-notes">Platform and Version Notes</h2>
<ul>
<li>Available in all VB6 versions</li>
<li>Part of VBA core functions</li>
<li>Returns <code>Variant</code> containing <code>String</code> (<code>LCase$</code> returns <code>String</code> type)</li>
<li>Locale-aware in some implementations</li>
<li>Only converts A-Z in most locales</li>
<li>Accented characters may or may not be converted depending on locale</li>
</ul>
<h2 id="limitations">Limitations</h2>
<ul>
<li>Only converts standard ASCII uppercase letters (A-Z)</li>
<li>Accented characters may not be converted consistently</li>
<li>Does not handle Unicode case mapping comprehensively</li>
<li>Cannot convert specific ranges of characters</li>
<li>No option to preserve certain characters</li>
<li>Creates new string (cannot modify in place)</li>
</ul>
<h2 id="related-functions">Related Functions</h2>
<ul>
<li><code>UCase</code>: Convert string to uppercase</li>
<li><code>StrComp</code>: Compare strings with case options</li>
<li><code>Trim</code>/<code>LTrim</code>/<code>RTrim</code>: Remove whitespace</li>
<li><code>Replace</code>: Replace substrings (with case-sensitive option)</li>
<li><code>InStr</code>: Find substring (can be case-insensitive)</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>