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
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
//! # `Error` Function
//!
//! Returns the error message that corresponds to a given error number.
//!
//! ## Syntax
//!
//! ```vb
//! Error[(errornumber)]
//! ```
//!
//! ## Parameters
//!
//! - **errornumber**: Optional. A Long or any valid numeric expression that represents
//! an error number. If omitted, the error message for the most recent run-time error
//! (the current value of `Err.Number`) is returned.
//!
//! ## Return Value
//!
//! Returns a `String` containing the error message associated with the specified error number.
//! If the error number is not recognized, `Error` returns "Application-defined or object-defined error".
//!
//! ## Remarks
//!
//! The `Error` function is used to retrieve the text description of VB6 run-time errors.
//! It's useful for error handling, logging, and displaying user-friendly error messages.
//!
//! **Important Characteristics:**
//!
//! - Returns error message as `String`
//! - Without argument, returns message for current error (`Err.Number`)
//! - With argument, returns message for specified error number
//! - VB6 error numbers range from 0 to 65535
//! - User-defined errors typically use 512-65535 range
//! - System errors use 0-511 range
//! - Unrecognized errors return generic message
//! - Does not clear or raise errors
//! - Can be used without On Error statement
//! - `Err.Description` also provides error messages
//!
//! ## Common VB6 Error Numbers
//!
//! - **3**: Return without `GoSub`
//! - **5**: Invalid procedure call or argument
//! - **6**: Overflow
//! - **7**: Out of memory
//! - **9**: Subscript out of range
//! - **10**: Array is fixed or temporarily locked
//! - **11**: Division by zero
//! - **13**: Type mismatch
//! - **28**: Out of stack space
//! - **35**: Sub or Function not defined
//! - **48**: Error in loading DLL
//! - **49**: Bad DLL calling convention
//! - **51**: Internal error
//! - **52**: Bad file name or number
//! - **53**: File not found
//! - **54**: Bad file mode
//! - **55**: File already open
//! - **57**: Device I/O error
//! - **58**: File already exists
//! - **61**: Disk full
//! - **62**: Input past end of file
//! - **63**: Bad record number
//! - **67**: Too many files
//! - **68**: Device unavailable
//! - **70**: Permission denied
//! - **71**: Disk not ready
//! - **74**: Can't rename with different drive
//! - **75**: Path/File access error
//! - **76**: Path not found
//! - **91**: `Object` variable or `With` block variable not set
//! - **92**: For loop not initialized
//! - **93**: Invalid pattern string
//! - **94**: Invalid use of Null
//! - **298**: System DLL could not be loaded
//! - **321**: Invalid file format
//! - **322**: Can't create necessary temporary file
//! - **325**: Invalid format in resource file
//! - **380**: Invalid property value
//! - **424**: `Object` required
//! - **429**: `ActiveX` component can't create `Object`
//! - **430**: Class does not support Automation
//! - **432**: File name or class name not found during Automation operation
//! - **438**: `Object` doesn't support this property or method
//! - **440**: Automation error
//! - **445**: `Object` doesn't support this action
//! - **446**: `Object` doesn't support named arguments
//! - **447**: `Object` doesn't support current locale setting
//! - **448**: Named argument not found
//! - **449**: Argument not optional
//! - **450**: Wrong number of arguments or invalid property assignment
//! - **451**: `Object` not a collection
//! - **452**: Invalid ordinal
//! - **453**: Specified DLL function not found
//! - **454**: Code resource not found
//! - **455**: Code resource lock error
//! - **457**: This key is already associated with an element of this collection
//! - **458**: Variable uses an Automation type not supported in Visual Basic
//! - **459**: This component doesn't support events
//! - **460**: Invalid Clipboard format
//! - **461**: Specified format doesn't match format of data
//! - **480**: Can't create `AutoRedraw` image
//! - **481**: Invalid picture
//! - **482**: Printer error
//! - **735**: Can't save file to TEMP
//! - **744**: Search text not found
//! - **746**: Replacements too long
//!
//! ## Examples
//!
//! ### Basic Usage
//!
//! ```vb
//! ' Get error message for specific error number
//! Dim msg As String
//! msg = Error(53)
//! Debug.Print msg ' Prints: "File not found"
//!
//! msg = Error(11)
//! Debug.Print msg ' Prints: "Division by zero"
//! ```
//!
//! ### Get Current Error Message
//!
//! ```vb
//! Sub TestErrorHandling()
//! On Error Resume Next
//!
//! ' Cause an error
//! Dim x As Integer
//! x = 1 / 0
//!
//! ' Check if error occurred
//! If Err.Number <> 0 Then
//! ' Get error message without parameter (uses current error)
//! Debug.Print "Error: " & Error
//! Debug.Print "Error number: " & Err.Number
//! Err.Clear
//! End If
//! End Sub
//! ```
//!
//! ### Display Error in Message Box
//!
//! ```vb
//! Sub OpenFileWithErrorHandling(filePath As String)
//! On Error GoTo ErrorHandler
//!
//! Dim fileNum As Integer
//! fileNum = FreeFile
//! Open filePath For Input As #fileNum
//! ' Process file...
//! Close #fileNum
//! Exit Sub
//!
//! ErrorHandler:
//! MsgBox "Error " & Err.Number & ": " & Error(Err.Number), _
//! vbExclamation, "File Error"
//! End Sub
//! ```
//!
//! ## Common Patterns
//!
//! ### Error Lookup Table
//!
//! ```vb
//! Function GetErrorMessage(errorNumber As Long) As String
//! ' Get standard VB6 error message
//! GetErrorMessage = Error(errorNumber)
//!
//! ' Override with custom messages if desired
//! Select Case errorNumber
//! Case 53
//! GetErrorMessage = "The specified file could not be found. Please check the path."
//! Case 61
//! GetErrorMessage = "The disk is full. Please free up space and try again."
//! Case 91
//! GetErrorMessage = "Object variable not initialized. Please contact support."
//! End Select
//! End Function
//! ```
//!
//! ### Error Logging
//!
//! ```vb
//! Sub LogError(procedureName As String)
//! Dim fileNum As Integer
//! Dim logPath As String
//!
//! logPath = App.Path & "\error.log"
//! fileNum = FreeFile
//!
//! Open logPath For Append As #fileNum
//! Print #fileNum, Format(Now, "yyyy-mm-dd hh:nn:ss") & " | " & _
//! procedureName & " | " & _
//! "Error " & Err.Number & ": " & Error(Err.Number)
//! Close #fileNum
//! End Sub
//! ```
//!
//! ### Custom Error Messages
//!
//! ```vb
//! Function GetFriendlyErrorMessage(errorNumber As Long) As String
//! Dim standardMsg As String
//! standardMsg = Error(errorNumber)
//!
//! ' Provide user-friendly alternatives
//! Select Case errorNumber
//! Case 53 ' File not found
//! GetFriendlyErrorMessage = "We couldn't find that file. " & _
//! "It may have been moved or deleted."
//!
//! Case 70 ' Permission denied
//! GetFriendlyErrorMessage = "You don't have permission to access this file. " & _
//! "Please contact your administrator."
//!
//! Case 429 ' Can't create object
//! GetFriendlyErrorMessage = "A required component is not installed. " & _
//! "Please reinstall the application."
//!
//! Case Else
//! GetFriendlyErrorMessage = standardMsg
//! End Select
//! End Function
//! ```
//!
//! ### Error Report Dialog
//!
//! ```vb
//! Sub ShowErrorReport()
//! Dim msg As String
//!
//! msg = "An error has occurred:" & vbCrLf & vbCrLf
//! msg = msg & "Error Number: " & Err.Number & vbCrLf
//! msg = msg & "Description: " & Error(Err.Number) & vbCrLf
//! msg = msg & "Source: " & Err.Source & vbCrLf
//!
//! If Err.HelpFile <> "" Then
//! msg = msg & "Help File: " & Err.HelpFile & vbCrLf
//! msg = msg & "Help Context: " & Err.HelpContext & vbCrLf
//! End If
//!
//! MsgBox msg, vbCritical, "Application Error"
//! End Sub
//! ```
//!
//! ### Validate Error Numbers
//!
//! ```vb
//! Function IsValidErrorNumber(errNum As Long) As Boolean
//! Dim msg As String
//!
//! ' Get error message
//! msg = Error(errNum)
//!
//! ' If it's not a recognized error, VB6 returns a generic message
//! If InStr(msg, "Application-defined") > 0 Or _
//! InStr(msg, "object-defined") > 0 Then
//! IsValidErrorNumber = False
//! Else
//! IsValidErrorNumber = True
//! End If
//! End Function
//! ```
//!
//! ### List Common Errors
//!
//! ```vb
//! Sub ListCommonErrors()
//! Dim errorNumbers() As Long
//! Dim i As Integer
//!
//! errorNumbers = Array(5, 6, 7, 9, 11, 13, 52, 53, 54, 61, 62, 70, 91, 429)
//!
//! Debug.Print "Common VB6 Errors:"
//! Debug.Print String(50, "-")
//!
//! For i = LBound(errorNumbers) To UBound(errorNumbers)
//! Debug.Print errorNumbers(i) & ": " & Error(errorNumbers(i))
//! Next i
//! End Sub
//! ```
//!
//! ### Enhanced Error Handler
//!
//! ```vb
//! Function HandleError(moduleName As String, procedureName As String) As VbMsgBoxResult
//! Dim msg As String
//! Dim errorMsg As String
//!
//! errorMsg = Error(Err.Number)
//!
//! msg = "An error occurred in " & moduleName & "." & procedureName & vbCrLf & vbCrLf
//! msg = msg & "Error " & Err.Number & ": " & errorMsg & vbCrLf & vbCrLf
//! msg = msg & "Would you like to continue?"
//!
//! HandleError = MsgBox(msg, vbYesNo + vbExclamation, "Error")
//!
//! ' Log the error
//! LogError moduleName & "." & procedureName
//!
//! ' Clear the error
//! Err.Clear
//! End Function
//! ```
//!
//! ### Error Dictionary
//!
//! ```vb
//! Function BuildErrorDictionary() As Collection
//! Dim dict As New Collection
//! Dim i As Long
//! Dim msg As String
//!
//! ' Build dictionary of all valid error messages
//! For i = 3 To 1000
//! msg = Error(i)
//!
//! ' Only add if it's a recognized error
//! If InStr(msg, "Application-defined") = 0 Then
//! On Error Resume Next
//! dict.Add msg, CStr(i)
//! On Error GoTo 0
//! End If
//! Next i
//!
//! Set BuildErrorDictionary = dict
//! End Function
//! ```
//!
//! ### Multilingual Error Messages
//!
//! ```vb
//! Function GetLocalizedError(errorNumber As Long, language As String) As String
//! Dim standardMsg As String
//! standardMsg = Error(errorNumber)
//!
//! ' Provide translations for common errors
//! If language = "ES" Then ' Spanish
//! Select Case errorNumber
//! Case 53: GetLocalizedError = "Archivo no encontrado"
//! Case 61: GetLocalizedError = "Disco lleno"
//! Case 70: GetLocalizedError = "Permiso denegado"
//! Case Else: GetLocalizedError = standardMsg
//! End Select
//! ElseIf language = "FR" Then ' French
//! Select Case errorNumber
//! Case 53: GetLocalizedError = "Fichier non trouvé"
//! Case 61: GetLocalizedError = "Disque plein"
//! Case 70: GetLocalizedError = "Permission refusée"
//! Case Else: GetLocalizedError = standardMsg
//! End Select
//! Else
//! GetLocalizedError = standardMsg
//! End If
//! End Function
//! ```
//!
//! ### Error Testing Helper
//!
//! ```vb
//! Sub TestErrorMessages()
//! Dim testErrors() As Long
//! Dim i As Integer
//!
//! ' Test specific error numbers
//! testErrors = Array(5, 6, 7, 9, 11, 13, 52, 53, 54, 55, 57, 58, 61, 62, _
//! 67, 68, 70, 71, 74, 75, 76, 91, 92, 93, 94)
//!
//! For i = LBound(testErrors) To UBound(testErrors)
//! Debug.Print "Error " & testErrors(i) & ": " & Error(testErrors(i))
//! Next i
//! End Sub
//! ```
//!
//! ## Advanced Usage
//!
//! ### Error Mapper with Suggestions
//!
//! ```vb
//! Type ErrorInfo
//! Number As Long
//! Message As String
//! Suggestion As String
//! End Type
//!
//! Function GetErrorInfo(errorNumber As Long) As ErrorInfo
//! Dim info As ErrorInfo
//!
//! info.Number = errorNumber
//! info.Message = Error(errorNumber)
//!
//! ' Add helpful suggestions
//! Select Case errorNumber
//! Case 53
//! info.Suggestion = "Check the file path and ensure the file exists."
//! Case 61
//! info.Suggestion = "Free up disk space or choose a different location."
//! Case 70
//! info.Suggestion = "Run the application as administrator or check file permissions."
//! Case 91
//! info.Suggestion = "Ensure the object is initialized with New or Set."
//! Case 429
//! info.Suggestion = "Verify that all required DLLs and components are registered."
//! Case Else
//! info.Suggestion = "Please contact technical support if the problem persists."
//! End Select
//!
//! GetErrorInfo = info
//! End Function
//! ```
//!
//! ### Comprehensive Error Logger
//!
//! ```vb
//! Sub LogDetailedError(moduleName As String, procedureName As String, _
//! Optional additionalInfo As String = "")
//! Dim fileNum As Integer
//! Dim logPath As String
//! Dim logEntry As String
//!
//! logPath = App.Path & "\logs\error_" & Format(Now, "yyyymmdd") & ".log"
//!
//! ' Build detailed log entry
//! logEntry = String(80, "=") & vbCrLf
//! logEntry = logEntry & "Timestamp: " & Format(Now, "yyyy-mm-dd hh:nn:ss") & vbCrLf
//! logEntry = logEntry & "Module: " & moduleName & vbCrLf
//! logEntry = logEntry & "Procedure: " & procedureName & vbCrLf
//! logEntry = logEntry & "Error Number: " & Err.Number & vbCrLf
//! logEntry = logEntry & "Error Message: " & Error(Err.Number) & vbCrLf
//! logEntry = logEntry & "Error Source: " & Err.Source & vbCrLf
//!
//! If additionalInfo <> "" Then
//! logEntry = logEntry & "Additional Info: " & additionalInfo & vbCrLf
//! End If
//!
//! logEntry = logEntry & String(80, "=") & vbCrLf & vbCrLf
//!
//! ' Write to log file
//! fileNum = FreeFile
//! Open logPath For Append As #fileNum
//! Print #fileNum, logEntry
//! Close #fileNum
//! End Sub
//! ```
//!
//! ### Error Recovery System
//!
//! ```vb
//! Function AttemptRecovery(errorNumber As Long) As Boolean
//! Dim errorMsg As String
//!
//! errorMsg = Error(errorNumber)
//! AttemptRecovery = False
//!
//! Select Case errorNumber
//! Case 53 ' File not found
//! ' Try to create the file or directory
//! On Error Resume Next
//! MkDir GetParentDirectory(expectedFilePath)
//! CreateDefaultFile expectedFilePath
//! If Err.Number = 0 Then AttemptRecovery = True
//! On Error GoTo 0
//!
//! Case 61 ' Disk full
//! ' Try to clean temp files
//! On Error Resume Next
//! CleanTempFiles
//! If GetFreeDiskSpace() > 1048576 Then AttemptRecovery = True
//! On Error GoTo 0
//!
//! Case 70 ' Permission denied
//! ' Prompt user to run as administrator
//! MsgBox "This operation requires administrator privileges. " & _
//! "Please restart the application as administrator.", vbExclamation
//! AttemptRecovery = False
//!
//! Case 91 ' Object not set
//! ' Try to reinitialize object
//! On Error Resume Next
//! InitializeObjects
//! If Err.Number = 0 Then AttemptRecovery = True
//! On Error GoTo 0
//! End Select
//! End Function
//! ```
//!
//! ### Error Statistics Tracker
//!
//! ```vb
//! Type ErrorStat
//! ErrorNumber As Long
//! ErrorMessage As String
//! OccurrenceCount As Long
//! LastOccurrence As Date
//! End Type
//!
//! Private errorStats() As ErrorStat
//! Private statCount As Long
//!
//! Sub TrackError(errorNumber As Long)
//! Dim i As Long
//! Dim found As Boolean
//!
//! ' Find existing error in stats
//! found = False
//! For i = 0 To statCount - 1
//! If errorStats(i).ErrorNumber = errorNumber Then
//! errorStats(i).OccurrenceCount = errorStats(i).OccurrenceCount + 1
//! errorStats(i).LastOccurrence = Now
//! found = True
//! Exit For
//! End If
//! Next i
//!
//! ' Add new error to stats
//! If Not found Then
//! ReDim Preserve errorStats(0 To statCount)
//! errorStats(statCount).ErrorNumber = errorNumber
//! errorStats(statCount).ErrorMessage = Error(errorNumber)
//! errorStats(statCount).OccurrenceCount = 1
//! errorStats(statCount).LastOccurrence = Now
//! statCount = statCount + 1
//! End If
//! End Sub
//!
//! Function GetErrorStatistics() As String
//! Dim i As Long
//! Dim report As String
//!
//! report = "Error Statistics Report" & vbCrLf
//! report = report & String(80, "-") & vbCrLf & vbCrLf
//!
//! For i = 0 To statCount - 1
//! With errorStats(i)
//! report = report & "Error " & .ErrorNumber & ": " & .ErrorMessage & vbCrLf
//! report = report & " Occurrences: " & .OccurrenceCount & vbCrLf
//! report = report & " Last Seen: " & Format(.LastOccurrence, "yyyy-mm-dd hh:nn:ss") & vbCrLf & vbCrLf
//! End With
//! Next i
//!
//! GetErrorStatistics = report
//! End Function
//! ```
//!
//! ### Email Error Notification
//!
//! ```vb
//! Sub SendErrorNotification(errorNumber As Long, context As String)
//! Dim emailBody As String
//! Dim errorMsg As String
//!
//! errorMsg = Error(errorNumber)
//!
//! emailBody = "An error occurred in the application:" & vbCrLf & vbCrLf
//! emailBody = emailBody & "Error Number: " & errorNumber & vbCrLf
//! emailBody = emailBody & "Error Message: " & errorMsg & vbCrLf
//! emailBody = emailBody & "Context: " & context & vbCrLf
//! emailBody = emailBody & "User: " & Environ("USERNAME") & vbCrLf
//! emailBody = emailBody & "Computer: " & Environ("COMPUTERNAME") & vbCrLf
//! emailBody = emailBody & "Timestamp: " & Format(Now, "yyyy-mm-dd hh:nn:ss") & vbCrLf
//!
//! ' Send email (pseudo-code)
//! SendEmail "admin@company.com", "Application Error", emailBody
//! End Sub
//! ```
//!
//! ### Error-Based Retry Logic
//!
//! ```vb
//! Function ExecuteWithRetry(operation As String, maxRetries As Integer) As Boolean
//! Dim retryCount As Integer
//! Dim errorMsg As String
//!
//! retryCount = 0
//!
//! Do
//! On Error Resume Next
//!
//! ' Attempt operation
//! ExecuteOperation operation
//!
//! If Err.Number = 0 Then
//! ExecuteWithRetry = True
//! Exit Function
//! End If
//!
//! ' Get error message
//! errorMsg = Error(Err.Number)
//!
//! ' Check if error is retryable
//! Select Case Err.Number
//! Case 57, 68 ' Device I/O error, Device unavailable
//! retryCount = retryCount + 1
//! If retryCount < maxRetries Then
//! Debug.Print "Retry " & retryCount & " after error: " & errorMsg
//! Sleep 1000 ' Wait before retry
//! End If
//!
//! Case Else ' Non-retryable error
//! Debug.Print "Non-retryable error: " & errorMsg
//! Exit Do
//! End Select
//!
//! On Error GoTo 0
//! Loop While retryCount < maxRetries
//!
//! ExecuteWithRetry = False
//! End Function
//! ```
//!
//! ## Error Handling Best Practices
//!
//! ```vb
//! ' Good - Use Error function for logging and display
//! Sub ProcessFile(filePath As String)
//! On Error GoTo ErrorHandler
//!
//! ' Processing code...
//!
//! Exit Sub
//!
//! ErrorHandler:
//! Dim errorMsg As String
//! errorMsg = Error(Err.Number)
//!
//! LogError "ProcessFile", errorMsg
//! MsgBox "Failed to process file: " & errorMsg, vbExclamation
//! Err.Clear
//! End Sub
//!
//! ' Good - Compare with Err.Description
//! Sub CompareErrorSources()
//! On Error Resume Next
//! Dim x As Integer
//! x = 1 / 0
//!
//! Debug.Print "Error function: " & Error(Err.Number)
//! Debug.Print "Err.Description: " & Err.Description
//! ' Both typically return the same message
//! End Sub
//! ```
//!
//! ## Performance Considerations
//!
//! - `Error` function is very fast (simple lookup)
//! - No performance difference between `Error()` and `Error(n)`
//! - Message strings are pre-defined in VB6 runtime
//! - Consider caching messages if calling repeatedly
//! - Minimal overhead for error message retrieval
//!
//! ## Comparison with Other Error Functions
//!
//! ### `Error` vs `Err.Description`
//!
//! ```vb
//! ' Error() - Returns message for specified or current error
//! msg = Error(53) ' "File not found"
//! msg = Error() ' Current error message
//!
//! ' Err.Description - Always current error message
//! msg = Err.Description ' Current error message only
//! ```
//!
//! ### `Error` vs `Err.Raise`
//!
//! ```vb
//! ' Error() - Retrieves error message (does not raise)
//! msg = Error(5) ' Just gets the message
//!
//! ' Err.Raise - Raises an error
//! Err.Raise 5 ' Triggers error 5
//! ```
//!
//! ## Limitations
//!
//! - Returns only standard VB6 error messages
//! - Cannot customize built-in messages
//! - Unrecognized error numbers return generic message
//! - Does not provide error context or call stack
//! - Limited to VB6 error number range
//! - No support for system error codes directly
//!
//! ## Related Functions
//!
//! - `Err.Number`: Returns the current error number
//! - `Err.Description`: Returns the current error description
//! - `Err.Raise`: Raises a run-time error
//! - `Err.Clear`: Clears current error information
//! - `CVErr`: Creates an error value
//! - `IsError`: Tests if a variant contains an error value
use crateVBResult;
use crateVBVariant;
use error_dollar;
/// Returns the error message corresponding to an error number, exactly as
/// [`error_dollar`] does.
///
/// `Error` is the Variant-returning counterpart of `Error$`; its runtime
/// semantics are otherwise identical (per the VBAL specification, the two
/// functions differ only in the declared type of the return value).