<!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 - ucase_dollar - String">
<title>ucase_dollar - 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> / ucase_dollar</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="ucase-function">UCase$ Function</h1>
<p>Returns a <code>String</code> that has been converted to uppercase.
The "$" suffix indicates this function returns a <code>String</code> type.</p>
<h2 id="syntax">Syntax</h2>
<pre><code class="language-vbnet">UCase$(string)</code></pre>
<h2 id="parameters">Parameters</h2>
<ul>
<li><strong>string</strong>: Required. Any valid string expression. If <code>string</code> contains <code>Null</code>, <code>Null</code> is returned.</li>
</ul>
<h2 id="returns">Returns</h2>
<p>Returns a <code>String</code> with all lowercase letters converted to uppercase. Numbers and punctuation
are unchanged.</p>
<h2 id="remarks">Remarks</h2>
<ul>
<li><code>UCase$</code> converts all lowercase letters in a string to uppercase.</li>
<li>The "$" suffix explicitly indicates the function returns a <code>String</code> type rather than a <code>Variant</code>.</li>
<li>Only lowercase letters (a-z) are affected; uppercase letters and non-alphabetic characters remain unchanged.</li>
<li><code>UCase$</code> is functionally equivalent to <code>UCase</code>, but <code>UCase$</code> returns a <code>String</code> while <code>UCase</code> can return a <code>Variant</code>.</li>
<li>For better performance when you know the result is a string, use <code>UCase$</code>.</li>
<li>If the argument is <code>Null</code>, the function returns <code>Null</code>.</li>
<li>The conversion is based on the system locale settings.</li>
<li>For international characters, the behavior depends on the current code page.</li>
<li>The inverse function is <code>LCase$</code>, which converts strings to lowercase.</li>
<li>Common use cases include display formatting, SQL keywords, and creating constants.</li>
</ul>
<h2 id="typical-uses">Typical Uses</h2>
<ol>
<li><strong>Display formatting</strong> - Format text for display in uppercase</li>
<li><strong>SQL keyword generation</strong> - Create SQL queries with uppercase keywords</li>
<li><strong>Constant generation</strong> - Generate uppercase constant names</li>
<li><strong>File path normalization</strong> - Normalize file paths for case-insensitive systems</li>
<li><strong>Acronym formatting</strong> - Format acronyms and abbreviations</li>
<li><strong>Header text</strong> - Create uppercase headers for reports</li>
<li><strong>Code generation</strong> - Generate uppercase identifiers in code</li>
</ol>
<h2 id="basic-examples">Basic Examples</h2>
<pre><code class="language-vbnet">' Example 1: Simple conversion
Dim result As String
result = UCase$("hello") ' Returns "HELLO"</code></pre>
<pre><code class="language-vbnet">' Example 2: Mixed case
Dim text As String
text = UCase$("Hello World") ' Returns "HELLO WORLD"</code></pre>
<pre><code class="language-vbnet">' Example 3: With numbers and punctuation
Dim mixed As String
mixed = UCase$("abc123!@#") ' Returns "ABC123!@#"</code></pre>
<pre><code class="language-vbnet">' Example 4: Already uppercase
Dim upper As String
upper = UCase$("ALREADY UPPERCASE") ' Returns "ALREADY UPPERCASE"</code></pre>
<h2 id="common-patterns">Common Patterns</h2>
<h3 id="sql-keyword-formatting">SQL Keyword Formatting</h3>
<pre><code class="language-vbnet">Function BuildSQLQuery(table As String, field As String) As String
BuildSQLQuery = UCase$("SELECT") & " * " & UCase$("FROM") & " " & table
End Function</code></pre>
<h3 id="constant-name-generator">Constant Name Generator</h3>
<pre><code class="language-vbnet">Function GenerateConstantName(baseName As String) As String
GenerateConstantName = UCase$(Replace(baseName, " ", "_"))
End Function</code></pre>
<h3 id="acronym-formatter">Acronym Formatter</h3>
<pre><code class="language-vbnet">Function FormatAcronym(text As String) As String
FormatAcronym = UCase$(text)
End Function</code></pre>
<h3 id="header-text-generator">Header Text Generator</h3>
<pre><code class="language-vbnet">Function CreateHeader(title As String) As String
CreateHeader = String$(Len(title), "=") & vbCrLf & _
UCase$(title) & vbCrLf & _
String$(Len(title), "=")
End Function</code></pre>
<h3 id="case-insensitive-command-comparison">Case-Insensitive Command Comparison</h3>
<pre><code class="language-vbnet">Function ProcessCommand(cmd As String) As Boolean
Select Case UCase$(Trim$(cmd))
Case "START"
ProcessCommand = StartService()
Case "STOP"
ProcessCommand = StopService()
Case "RESTART"
ProcessCommand = RestartService()
Case Else
ProcessCommand = False
End Select
End Function</code></pre>
<h3 id="file-extension-normalization">File Extension Normalization</h3>
<pre><code class="language-vbnet">Function NormalizeExtension(filename As String) As String
Dim ext As String
ext = Right$(filename, 4)
If UCase$(ext) = ".TXT" Then
NormalizeExtension = "Text File"
End If
End Function</code></pre>
<h3 id="environment-variable-names">Environment Variable Names</h3>
<pre><code class="language-vbnet">Function GetEnvironmentVar(varName As String) As String
GetEnvironmentVar = Environ$(UCase$(varName))
End Function</code></pre>
<h3 id="registry-key-normalization">Registry Key Normalization</h3>
<pre><code class="language-vbnet">Function NormalizeRegistryKey(keyName As String) As String
NormalizeRegistryKey = UCase$(Trim$(keyName))
End Function</code></pre>
<h3 id="display-name-formatting">Display Name Formatting</h3>
<pre><code class="language-vbnet">Function FormatDisplayName(firstName As String, lastName As String) As String
FormatDisplayName = UCase$(lastName) & ", " & firstName
End Function</code></pre>
<h3 id="code-template-generator">Code Template Generator</h3>
<pre><code class="language-vbnet">Function GenerateEnumMember(memberName As String) As String
GenerateEnumMember = " " & UCase$(memberName) & " = " & counter
End Function</code></pre>
<h2 id="advanced-examples">Advanced Examples</h2>
<h3 id="sql-query-builder-with-uppercase-keywords">SQL Query Builder with Uppercase Keywords</h3>
<pre><code class="language-vbnet">Function BuildComplexQuery(table As String, fields As String, whereClause As String) As String
Dim sql As String
sql = UCase$("SELECT") & " " & fields & " "
sql = sql & UCase$("FROM") & " " & table
If Len(whereClause) > 0 Then
sql = sql & " " & UCase$("WHERE") & " " & whereClause
End If
BuildComplexQuery = sql
End Function</code></pre>
<h3 id="configuration-file-writer">Configuration File Writer</h3>
<pre><code class="language-vbnet">Sub WriteConfigSection(fileNum As Integer, sectionName As String, settings As Collection)
Dim key As Variant
Print #fileNum, "[" & UCase$(sectionName) & "]"
For Each key In settings
Print #fileNum, UCase$(key) & "=" & settings(key)
Next key
Print #fileNum, ""
End Sub</code></pre>
<h3 id="report-header-generator">Report Header Generator</h3>
<pre><code class="language-vbnet">Function GenerateReportHeader(reportTitle As String, reportDate As String) As String
Dim header As String
Dim separator As String
separator = String$(60, "=")
header = separator & vbCrLf
header = header & Space$((60 - Len(reportTitle)) \ 2) & UCase$(reportTitle) & vbCrLf
header = header & Space$((60 - Len(reportDate)) \ 2) & reportDate & vbCrLf
header = header & separator & vbCrLf
GenerateReportHeader = header
End Function</code></pre>
<h3 id="macro-name-validator">Macro Name Validator</h3>
<pre><code class="language-vbnet">Function ValidateMacroName(macroName As String) As String
Dim validName As String
Dim i As Long
Dim char As String
' Convert to uppercase and remove invalid characters
validName = UCase$(macroName)
For i = 1 To Len(validName)
char = Mid$(validName, i, 1)
If (char >= "A" And char <= "Z") Or _
(char >= "0" And char <= "9") Or _
char = "_" Then
ValidateMacroName = ValidateMacroName & char
End If
Next i
End Function</code></pre>
<h2 id="error-handling">Error Handling</h2>
<pre><code class="language-vbnet">Function SafeUCase(text As String) As String
On Error GoTo ErrorHandler
If IsNull(text) Then
SafeUCase = ""
Exit Function
End If
SafeUCase = UCase$(text)
Exit Function
ErrorHandler:
SafeUCase = ""
End Function</code></pre>
<h2 id="performance-notes">Performance Notes</h2>
<ul>
<li><code>UCase$</code> is a fast operation with minimal overhead</li>
<li>For large strings, the performance is linear with string length</li>
<li><code>UCase$</code> (returns <code>String</code>) is slightly faster than <code>UCase</code> (returns <code>Variant</code>)</li>
<li>When formatting multiple strings, consider caching uppercase versions if reused</li>
<li>For very large datasets, consider using database-level text functions</li>
</ul>
<h2 id="best-practices">Best Practices</h2>
<ol>
<li><strong>Use for display</strong> - Convert to uppercase when formatting for display</li>
<li><strong>Prefer <code>UCase$</code> over <code>UCase</code></strong> - Use <code>UCase$</code> when you know the result is a string</li>
<li><strong>SQL keywords</strong> - Use uppercase for SQL keywords to improve readability</li>
<li><strong>Handle Null</strong> - Check for <code>Null</code> values before calling <code>UCase$</code></li>
<li><strong>Combine with Trim</strong> - Often useful to combine <code>UCase$</code> with <code>Trim$</code> for cleaner output</li>
<li><strong>Document intent</strong> - Make it clear when uppercase conversion is for display vs. comparison</li>
<li><strong>Consider locale</strong> - Be aware that conversion may vary by system locale</li>
</ol>
<h2 id="comparison-with-related-functions">Comparison with Related Functions</h2>
<table>
<thead>
<tr>
<th>Function</th>
<th>Return Type</th>
<th>Conversion</th>
<th>Use Case</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>UCase</code></td>
<td>Variant</td>
<td>To uppercase</td>
<td>When working with Variant types</td>
</tr>
<tr>
<td><code>UCase$</code></td>
<td>String</td>
<td>To uppercase</td>
<td>When result is definitely a string</td>
</tr>
<tr>
<td><code>LCase</code></td>
<td>Variant</td>
<td>To lowercase</td>
<td>Convert to lowercase (Variant)</td>
</tr>
<tr>
<td><code>LCase$</code></td>
<td>String</td>
<td>To lowercase</td>
<td>Convert to lowercase (String)</td>
</tr>
<tr>
<td><code>StrConv</code></td>
<td>String</td>
<td>Various conversions</td>
<td>Complex case conversions</td>
</tr>
</tbody>
</table>
<h2 id="common-use-cases">Common Use Cases</h2>
<h3 id="http-header-names">HTTP Header Names</h3>
<pre><code class="language-vbnet">Function FormatHTTPHeader(headerName As String, headerValue As String) As String
FormatHTTPHeader = UCase$(headerName) & ": " & headerValue
End Function</code></pre>
<h3 id="database-column-names">Database Column Names</h3>
<pre><code class="language-vbnet">Function GetColumnName(fieldName As String) As String
GetColumnName = UCase$(Replace(fieldName, " ", "_"))
End Function</code></pre>
<h3 id="license-key-formatting">License Key Formatting</h3>
<pre><code class="language-vbnet">Function FormatLicenseKey(key As String) As String
' Format as XXXX-XXXX-XXXX-XXXX
Dim upperKey As String
upperKey = UCase$(Replace(key, "-", ""))
FormatLicenseKey = Mid$(upperKey, 1, 4) & "-" & _
Mid$(upperKey, 5, 4) & "-" & _
Mid$(upperKey, 9, 4) & "-" & _
Mid$(upperKey, 13, 4)
End Function</code></pre>
<h3 id="command-line-argument-parsing">Command Line Argument Parsing</h3>
<pre><code class="language-vbnet">Function ParseArgument(arg As String) As String
If Left$(arg, 1) = "/" Or Left$(arg, 1) = "-" Then
ParseArgument = UCase$(Mid$(arg, 2))
Else
ParseArgument = UCase$(arg)
End If
End Function</code></pre>
<h2 id="platform-notes">Platform Notes</h2>
<ul>
<li>On Windows, <code>UCase$</code> respects the system locale for character conversion</li>
<li>Behavior may vary for extended ASCII and international characters</li>
<li>For ASCII characters (a-z), behavior is consistent across all platforms</li>
<li>Some characters may convert differently depending on the active code page</li>
<li>Modern Windows systems handle Unicode characters in <code>UCase$</code> operations</li>
</ul>
<h2 id="limitations">Limitations</h2>
<ul>
<li>Conversion is based on system locale; may not work as expected for all Unicode characters</li>
<li>Returns <code>Null</code> if the input is <code>Null</code> (unlike some other string functions that error)</li>
<li>Does not handle advanced Unicode normalization or case folding</li>
<li>For true Unicode case folding, more sophisticated methods may be needed</li>
<li>Some special characters may not convert in all locales</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>© 2024-2026 VB6Parse Contributors. Licensed under the MIT License.</p>
</div>
</footer>
</body>
</html>