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
<!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 - monthname - Datetime">
    <title>monthname - Datetime - 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/datetime/index.html">Datetime</a> / monthname</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="monthname-function">MonthName Function</h1>
<p>Returns a String indicating the specified month.</p>
<h2 id="syntax">Syntax</h2>
<pre><code class="language-vbnet">MonthName(month, [abbreviate])</code></pre>
<h2 id="parameters">Parameters</h2>
<ul>
<li><strong>month</strong> (Required) - Numeric designation of the month. For example, January is 1, February is 2, and so on.</li>
<li><strong>abbreviate</strong> (Optional) - Boolean value that indicates if the month name is to be abbreviated. If omitted, the default is False, which means the month name is not abbreviated.</li>
</ul>
<h2 id="return-value">Return Value</h2>
<p>Returns a <strong>String</strong> representing the month name:
- If abbreviate is False or omitted: Full month name (e.g., "January", "February")
- If abbreviate is True: Abbreviated month name (e.g., "Jan", "Feb")</p>
<h2 id="remarks">Remarks</h2>
<p>The <code>MonthName</code> function returns the localized name of the month based on the system's regional settings.
It is commonly used for displaying month names in user interfaces, reports, and formatted output.</p>
<h3 id="key-characteristics">Key Characteristics:</h3>
<ul>
<li>Returns localized month names based on system regional settings</li>
<li>Month parameter must be between 1 and 12</li>
<li>Error 5 (Invalid procedure call) if month is less than 1 or greater than 12</li>
<li>Abbreviate parameter is optional; defaults to False (full name)</li>
<li>Abbreviated names are typically 3 characters but may vary by locale</li>
<li>Much simpler than maintaining arrays of month names</li>
<li>Can be combined with <code>Month()</code> function for date formatting</li>
<li>Respects system locale for internationalization</li>
</ul>
<h3 id="common-use-cases">Common Use Cases:</h3>
<ul>
<li>Display month names in user interfaces</li>
<li>Format dates for reports and output</li>
<li>Create drop-down lists of months</li>
<li>Generate calendar displays</li>
<li>Internationalized date formatting</li>
<li>Chart and graph labels</li>
<li>File naming with month names</li>
<li>Data export with readable month names</li>
</ul>
<h2 id="typical-uses">Typical Uses</h2>
<ol>
<li><strong>Display Month Names</strong> - Convert month numbers to readable names</li>
<li><strong>Report Headers</strong> - Format report titles with month names</li>
<li><strong>Calendar Controls</strong> - Populate month selectors</li>
<li><strong>Data Export</strong> - Include readable month names in exports</li>
<li><strong>User Interface</strong> - Display current or selected month</li>
<li><strong>Chart Labels</strong> - Label chart axes with month names</li>
<li><strong>File Naming</strong> - Create month-based file names</li>
<li><strong>Internationalization</strong> - Automatic locale-based month names</li>
</ol>
<h2 id="basic-examples">Basic Examples</h2>
<pre><code class="language-vbnet">&#x27; Example 1: Get full month name
Dim monthName As String
monthName = MonthName(3)
&#x27; Returns &quot;March&quot;</code></pre>
<pre><code class="language-vbnet">&#x27; Example 2: Get abbreviated month name
Dim shortMonth As String
shortMonth = MonthName(11, True)
&#x27; Returns &quot;Nov&quot;</code></pre>
<pre><code class="language-vbnet">&#x27; Example 3: Display current month
Dim currentMonthName As String
currentMonthName = MonthName(Month(Date))
MsgBox &quot;Current month is &quot; &amp; currentMonthName</code></pre>
<pre><code class="language-vbnet">&#x27; Example 4: Format date with month name
Dim formattedDate As String
Dim d As Date
d = #5/15/2025#
formattedDate = MonthName(Month(d)) &amp; &quot; &quot; &amp; Day(d) &amp; &quot;, &quot; &amp; Year(d)
&#x27; Returns &quot;May 15, 2025&quot;</code></pre>
<h2 id="common-patterns">Common Patterns</h2>
<pre><code class="language-vbnet">&#x27; Pattern 1: Safe month name with validation
Function SafeMonthName(monthNumber As Integer, _
                       Optional abbreviate As Boolean = False) As String
    If monthNumber &lt; 1 Or monthNumber &gt; 12 Then
        SafeMonthName = &quot;&quot;
    Else
        SafeMonthName = MonthName(monthNumber, abbreviate)
    End If
End Function</code></pre>
<pre><code class="language-vbnet">&#x27; Pattern 2: Populate month combo box
Sub PopulateMonthCombo(cbo As ComboBox, Optional abbreviate As Boolean = False)
    Dim i As Integer
    cbo.Clear
    For i = 1 To 12
        cbo.AddItem MonthName(i, abbreviate)
    Next i
End Sub</code></pre>
<pre><code class="language-vbnet">&#x27; Pattern 3: Get month name from date
Function GetMonthNameFromDate(dateValue As Date, _
                              Optional abbreviate As Boolean = False) As String
    GetMonthNameFromDate = MonthName(Month(dateValue), abbreviate)
End Function</code></pre>
<pre><code class="language-vbnet">&#x27; Pattern 4: Format date range with month names
Function FormatDateRange(startDate As Date, endDate As Date) As String
    Dim startMonth As String
    Dim endMonth As String
    startMonth = MonthName(Month(startDate), True)
    endMonth = MonthName(Month(endDate), True)
    FormatDateRange = startMonth &amp; &quot; &quot; &amp; Day(startDate) &amp; &quot; - &quot; &amp; _
                      endMonth &amp; &quot; &quot; &amp; Day(endDate) &amp; &quot;, &quot; &amp; Year(endDate)
End Function</code></pre>
<pre><code class="language-vbnet">&#x27; Pattern 5: Create month-based filename
Function GetMonthlyFileName(fileDate As Date, fileType As String) As String
    Dim monthAbbrev As String
    monthAbbrev = MonthName(Month(fileDate), True)
    GetMonthlyFileName = fileType &amp; &quot;_&quot; &amp; Year(fileDate) &amp; &quot;_&quot; &amp; monthAbbrev &amp; &quot;.dat&quot;
End Function</code></pre>
<pre><code class="language-vbnet">&#x27; Pattern 6: Build month selection array
Function GetMonthArray(fullNames As Boolean) As String()
    Dim months() As String
    Dim i As Integer
    ReDim months(1 To 12)
    For i = 1 To 12
        months(i) = MonthName(i, Not fullNames)
    Next i
    GetMonthArray = months
End Function</code></pre>
<pre><code class="language-vbnet">&#x27; Pattern 7: Format month/year string
Function FormatMonthYear(dateValue As Date, abbreviate As Boolean) As String
    FormatMonthYear = MonthName(Month(dateValue), abbreviate) &amp; &quot; &quot; &amp; Year(dateValue)
End Function</code></pre>
<pre><code class="language-vbnet">&#x27; Pattern 8: Get fiscal month name
Function GetFiscalMonthName(fiscalMonth As Integer, abbreviate As Boolean) As String
    &#x27; Fiscal month 1 might be October (calendar month 10)
    Dim calendarMonth As Integer
    Dim fiscalStartMonth As Integer
    fiscalStartMonth = 10 &#x27; October
    calendarMonth = fiscalMonth + fiscalStartMonth - 1
    If calendarMonth &gt; 12 Then
        calendarMonth = calendarMonth - 12
    End If
    GetFiscalMonthName = MonthName(calendarMonth, abbreviate)
End Function</code></pre>
<pre><code class="language-vbnet">&#x27; Pattern 9: Create report header
Function CreateMonthlyReportHeader(reportDate As Date) As String
    Dim header As String
    header = &quot;Monthly Report - &quot; &amp; MonthName(Month(reportDate)) &amp; &quot; &quot; &amp; Year(reportDate)
    CreateMonthlyReportHeader = header
End Function</code></pre>
<pre><code class="language-vbnet">&#x27; Pattern 10: Compare month names
Function IsSameMonth(date1 As Date, date2 As Date) As Boolean
    IsSameMonth = (MonthName(Month(date1)) = MonthName(Month(date2))) And _
                  (Year(date1) = Year(date2))
End Function</code></pre>
<h2 id="advanced-usage">Advanced Usage</h2>
<h3 id="example-1-calendar-generator">Example 1: Calendar Generator</h3>
<pre><code class="language-vbnet">&#x27; Class: CalendarGenerator
&#x27; Generates formatted calendar displays
Option Explicit
Private m_year As Integer
Private m_month As Integer
Private m_firstDayOfWeek As VbDayOfWeek
Public Sub Initialize(calYear As Integer, calMonth As Integer)
    m_year = calYear
    m_month = calMonth
    m_firstDayOfWeek = vbSunday
End Sub
Public Function GetMonthHeader(abbreviate As Boolean) As String
    GetMonthHeader = MonthName(m_month, abbreviate) &amp; &quot; &quot; &amp; m_year
End Function
Public Function GenerateCalendar() As String
    Dim calendar As String
    Dim firstDay As Date
    Dim lastDay As Date
    Dim currentDay As Date
    Dim dayOfWeek As Integer
    Dim weekRow As String
    Dim dayCount As Integer
    &#x27; Create header
    calendar = String(28, &quot; &quot;) &amp; GetMonthHeader(False) &amp; vbCrLf
    calendar = calendar &amp; &quot;Su  Mo  Tu  We  Th  Fr  Sa&quot; &amp; vbCrLf
    &#x27; Get first and last day of month
    firstDay = DateSerial(m_year, m_month, 1)
    lastDay = DateSerial(m_year, m_month + 1, 0)
    &#x27; Start with padding for first week
    dayOfWeek = Weekday(firstDay, m_firstDayOfWeek)
    weekRow = String((dayOfWeek - 1) * 4, &quot; &quot;)
    &#x27; Fill in days
    currentDay = firstDay
    Do While currentDay &lt;= lastDay
        weekRow = weekRow &amp; Format(Day(currentDay), &quot;00&quot;) &amp; &quot;  &quot;
        dayOfWeek = dayOfWeek + 1
        If dayOfWeek &gt; 7 Then
            calendar = calendar &amp; weekRow &amp; vbCrLf
            weekRow = &quot;&quot;
            dayOfWeek = 1
        End If
        currentDay = DateAdd(&quot;d&quot;, 1, currentDay)
    Loop
    If Len(weekRow) &gt; 0 Then
        calendar = calendar &amp; weekRow &amp; vbCrLf
    End If
    GenerateCalendar = calendar
End Function
Public Function GetAllMonthsForYear(abbreviate As Boolean) As String()
    Dim months() As String
    Dim i As Integer
    ReDim months(1 To 12)
    For i = 1 To 12
        months(i) = MonthName(i, abbreviate)
    Next i
    GetAllMonthsForYear = months
End Function</code></pre>
<h3 id="example-2-report-generator-with-month-names">Example 2: Report Generator with Month Names</h3>
<pre><code class="language-vbnet">&#x27; Class: MonthlyReportFormatter
&#x27; Formats reports with localized month names
Option Explicit
Private m_useAbbreviations As Boolean
Private m_reportData As Collection
Public Sub Initialize(useAbbrev As Boolean)
    m_useAbbreviations = useAbbrev
    Set m_reportData = New Collection
End Sub
Public Sub AddMonthData(monthNum As Integer, dataValue As Double)
    Dim entry As String
    entry = MonthName(monthNum, m_useAbbreviations) &amp; &quot;:&quot; &amp; dataValue
    m_reportData.Add entry
End Sub
Public Function GenerateReport() As String
    Dim report As String
    Dim item As Variant
    Dim i As Integer
    report = &quot;Monthly Summary Report&quot; &amp; vbCrLf
    report = report &amp; String(50, &quot;-&quot;) &amp; vbCrLf
    For Each item In m_reportData
        report = report &amp; item &amp; vbCrLf
    Next item
    GenerateReport = report
End Function
Public Function FormatDateWithMonth(dateValue As Date) As String
    FormatDateWithMonth = MonthName(Month(dateValue), m_useAbbreviations) &amp; _
                         &quot; &quot; &amp; Day(dateValue) &amp; &quot;, &quot; &amp; Year(dateValue)
End Function
Public Function GetQuarterMonths(quarter As Integer) As String
    Dim months As String
    Dim startMonth As Integer
    Dim i As Integer
    startMonth = ((quarter - 1) * 3) + 1
    For i = 0 To 2
        If i &gt; 0 Then months = months &amp; &quot;, &quot;
        months = months &amp; MonthName(startMonth + i, m_useAbbreviations)
    Next i
    GetQuarterMonths = months
End Function</code></pre>
<h3 id="example-3-internationalized-date-formatter">Example 3: Internationalized Date Formatter</h3>
<pre><code class="language-vbnet">&#x27; Module: InternationalDateFormatter
&#x27; Provides locale-aware date formatting using MonthName
Option Explicit
Public Enum DateFormat
    dfLong = 0          &#x27; &quot;January 15, 2025&quot;
    dfMedium = 1        &#x27; &quot;Jan 15, 2025&quot;
    dfShort = 2         &#x27; &quot;01/15/2025&quot;
    dfMonthYear = 3     &#x27; &quot;January 2025&quot;
    dfMonthYearShort = 4 &#x27; &quot;Jan 2025&quot;
End Enum
Public Function FormatDate(dateValue As Date, formatType As DateFormat) As String
    Select Case formatType
        Case dfLong
            FormatDate = MonthName(Month(dateValue)) &amp; &quot; &quot; &amp; _
                        Day(dateValue) &amp; &quot;, &quot; &amp; Year(dateValue)
        Case dfMedium
            FormatDate = MonthName(Month(dateValue), True) &amp; &quot; &quot; &amp; _
                        Day(dateValue) &amp; &quot;, &quot; &amp; Year(dateValue)
        Case dfShort
            FormatDate = Format(dateValue, &quot;mm/dd/yyyy&quot;)
        Case dfMonthYear
            FormatDate = MonthName(Month(dateValue)) &amp; &quot; &quot; &amp; Year(dateValue)
        Case dfMonthYearShort
            FormatDate = MonthName(Month(dateValue), True) &amp; &quot; &quot; &amp; Year(dateValue)
    End Select
End Function
Public Function FormatDateRange(startDate As Date, endDate As Date, _
                               abbreviate As Boolean) As String
    Dim result As String
    If Year(startDate) = Year(endDate) Then
        If Month(startDate) = Month(endDate) Then
            &#x27; Same month and year
            result = MonthName(Month(startDate), abbreviate) &amp; &quot; &quot; &amp; _
                    Day(startDate) &amp; &quot;-&quot; &amp; Day(endDate) &amp; &quot;, &quot; &amp; Year(startDate)
        Else
            &#x27; Different months, same year
            result = MonthName(Month(startDate), abbreviate) &amp; &quot; &quot; &amp; Day(startDate) &amp; &quot; - &quot; &amp; _
                    MonthName(Month(endDate), abbreviate) &amp; &quot; &quot; &amp; Day(endDate) &amp; &quot;, &quot; &amp; _
                    Year(endDate)
        End If
    Else
        &#x27; Different years
        result = MonthName(Month(startDate), abbreviate) &amp; &quot; &quot; &amp; Day(startDate) &amp; &quot;, &quot; &amp; _
                Year(startDate) &amp; &quot; - &quot; &amp; _
                MonthName(Month(endDate), abbreviate) &amp; &quot; &quot; &amp; Day(endDate) &amp; &quot;, &quot; &amp; _
                Year(endDate)
    End If
    FormatDateRange = result
End Function
Public Function GetMonthNames(abbreviate As Boolean) As String()
    Dim months(1 To 12) As String
    Dim i As Integer
    For i = 1 To 12
        months(i) = MonthName(i, abbreviate)
    Next i
    GetMonthNames = months
End Function
Public Function ParseMonthName(monthString As String) As Integer
    Dim i As Integer
    &#x27; Try full names first
    For i = 1 To 12
        If UCase(MonthName(i)) = UCase(monthString) Then
            ParseMonthName = i
            Exit Function
        End If
    Next i
    &#x27; Try abbreviated names
    For i = 1 To 12
        If UCase(MonthName(i, True)) = UCase(monthString) Then
            ParseMonthName = i
            Exit Function
        End If
    Next i
    ParseMonthName = 0 &#x27; Not found
End Function</code></pre>
<h3 id="example-4-chart-label-generator">Example 4: Chart Label Generator</h3>
<pre><code class="language-vbnet">&#x27; Class: ChartLabelGenerator
&#x27; Generates chart labels with month names
Option Explicit
Private m_startMonth As Integer
Private m_monthCount As Integer
Private m_abbreviate As Boolean
Public Sub Initialize(startMonth As Integer, monthCount As Integer, _
                      abbreviate As Boolean)
    If startMonth &lt; 1 Or startMonth &gt; 12 Then
        Err.Raise 5, &quot;ChartLabelGenerator&quot;, &quot;Invalid start month&quot;
    End If
    m_startMonth = startMonth
    m_monthCount = monthCount
    m_abbreviate = abbreviate
End Sub
Public Function GetLabels() As String()
    Dim labels() As String
    Dim i As Integer
    Dim currentMonth As Integer
    ReDim labels(0 To m_monthCount - 1)
    For i = 0 To m_monthCount - 1
        currentMonth = m_startMonth + i
        &#x27; Wrap around if exceeds 12
        If currentMonth &gt; 12 Then
            currentMonth = currentMonth - 12
        End If
        labels(i) = MonthName(currentMonth, m_abbreviate)
    Next i
    GetLabels = labels
End Function
Public Function GetLabelWithYear(monthNum As Integer, yearNum As Integer) As String
    GetLabelWithYear = MonthName(monthNum, m_abbreviate) &amp; &quot; &#x27;&quot; &amp; _
                       Right(CStr(yearNum), 2)
End Function
Public Function GetQuarterLabel(quarter As Integer, yearNum As Integer) As String
    Dim firstMonth As Integer
    firstMonth = ((quarter - 1) * 3) + 1
    GetQuarterLabel = &quot;Q&quot; &amp; quarter &amp; &quot; (&quot; &amp; _
                     MonthName(firstMonth, True) &amp; &quot;-&quot; &amp; _
                     MonthName(firstMonth + 2, True) &amp; &quot; &quot; &amp; _
                     yearNum &amp; &quot;)&quot;
End Function
Public Function GetYearLabels(abbreviate As Boolean) As String()
    Dim labels(1 To 12) As String
    Dim i As Integer
    For i = 1 To 12
        labels(i) = MonthName(i, abbreviate)
    Next i
    GetYearLabels = labels
End Function
Public Function FormatMultiYearLabel(monthNum As Integer, _
                                    startYear As Integer, _
                                    endYear As Integer) As String
    FormatMultiYearLabel = MonthName(monthNum, m_abbreviate) &amp; &quot; &quot; &amp; _
                          startYear &amp; &quot;-&quot; &amp; endYear
End Function</code></pre>
<h2 id="error-handling">Error Handling</h2>
<pre><code class="language-vbnet">On Error Resume Next
monthName = MonthName(monthNum)
If Err.Number = 5 Then
    MsgBox &quot;Invalid month number. Must be between 1 and 12.&quot;
ElseIf Err.Number &lt;&gt; 0 Then
    MsgBox &quot;Error getting month name: &quot; &amp; Err.Description
End If
On Error GoTo 0</code></pre>
<h2 id="performance-considerations">Performance Considerations</h2>
<ul>
<li><code>MonthName()</code> is very fast - simple lookup operation</li>
<li>For repeated calls, consider caching month name arrays</li>
<li>No performance difference between full and abbreviated names</li>
<li>Locale lookup may add minimal overhead but is negligible</li>
<li>More efficient than maintaining hardcoded month name arrays</li>
<li>Can be called millions of times without performance concerns</li>
</ul>
<h2 id="best-practices">Best Practices</h2>
<ol>
<li><strong>Validate month numbers</strong> - Always check that month is 1-12 before calling</li>
<li><strong>Use for localization</strong> - Leverages system locale for international support</li>
<li><strong>Combine with <code>Month()</code></strong> - Extract month number from dates, then get name</li>
<li><strong>Consider abbreviations</strong> - Use abbreviated names for space-constrained displays</li>
<li><strong>Cache for UI</strong> - Populate drop-downs once, not on every refresh</li>
<li><strong>Document format</strong> - Clearly state whether full or abbreviated names are expected</li>
<li><strong>Test locales</strong> - Test with different regional settings for international apps</li>
<li><strong>Handle errors</strong> - Wrap in error handling for robust code</li>
<li><strong>Use constants</strong> - Define month number constants for readability</li>
<li><strong>Prefer over arrays</strong> - Use <code>MonthName()</code> instead of hardcoded name arrays</li>
</ol>
<h2 id="comparison-with-other-approaches">Comparison with Other Approaches</h2>
<table>
<thead>
<tr>
<th>Approach</th>
<th>Pros</th>
<th>Cons</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><code>MonthName()</code></strong></td>
<td>Automatic localization, simple, no maintenance</td>
<td>Requires VBA/VB6, slightly slower than array</td>
</tr>
<tr>
<td><strong>Hardcoded array</strong></td>
<td>Fast, full control</td>
<td>No localization, maintenance burden</td>
</tr>
<tr>
<td><strong><code>Format()</code></strong></td>
<td>Flexible formatting</td>
<td>Returns different formats, not just name</td>
</tr>
<tr>
<td><strong><code>DatePart()</code></strong></td>
<td>Returns number, not name</td>
<td>Need to convert to name separately</td>
</tr>
</tbody>
</table>
<h2 id="localization-notes">Localization Notes</h2>
<p>The <code>MonthName</code> function returns month names based on the system's regional settings:
- <strong>English (US)</strong>: "January", "February", etc. / "Jan", "Feb", etc.
- <strong>Spanish</strong>: "enero", "febrero", etc. / "ene", "feb", etc.
- <strong>French</strong>: "janvier", "février", etc. / "janv", "févr", etc.
- <strong>German</strong>: "Januar", "Februar", etc. / "Jan", "Feb", etc.
- <strong>Japanese</strong>: "1月", "2月", etc.
- And many more locales...</p>
<h2 id="platform-notes">Platform Notes</h2>
<ul>
<li>Available in VBA (Excel, Access, Word, etc.)</li>
<li>Available in VB6</li>
<li><strong>Not available in <code>VBScript</code></strong> (<code>VBScript</code> lacks this function)</li>
<li>Returns String type</li>
<li>Consistent across all VBA platforms</li>
<li>Uses Control Panel regional settings</li>
<li>First introduced in VB6 and VBA 6.0</li>
</ul>
<h2 id="limitations">Limitations</h2>
<ul>
<li>Month parameter must be 1-12 (no 0 or 13+)</li>
<li>Error 5 if month is out of valid range</li>
<li>Returns names based on system locale only (cannot specify locale)</li>
<li>Abbreviated length varies by locale (usually 3 chars, but not always)</li>
<li>Not available in <code>VBScript</code></li>
<li>Cannot customize the returned names</li>
</ul>
<h2 id="related-functions">Related Functions</h2>
<ul>
<li><strong>Month</strong> - Returns the month number (1-12) from a date</li>
<li><strong><code>WeekdayName</code></strong> - Returns the name of the weekday (similar function for days)</li>
<li><strong>Format</strong> - Can format dates with month names using format strings</li>
<li><strong><code>DatePart</code></strong> - Returns various parts of a date (including month number)</li>
<li><strong>Year</strong> - Returns the year component of a date</li>
<li><strong>Day</strong> - Returns the day component of a date</li>
</ul>
<h2 id="vb6-parser-notes">VB6 Parser Notes</h2>
<p><code>MonthName</code> is parsed as a regular function call (<code>CallExpression</code>). This module exists primarily
for documentation purposes to provide comprehensive reference material for VB6 developers
working with date formatting and display operations requiring localized month names.</p>
        </article>
        
        <div style="margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-color);">
            <p>
                <a href="index.html">← Back to Datetime</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>