Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Ran into "Run-time error '6': Overflow " while trying to execute a function that would suppose to return error codes

I am new to VBA and currently facing this issue. When I tried to execute "PriErrCod()" function, the program ran into error saying it overflow. I don’t quite understand how the error happened. Any answers and suggestions are welcome. Here is the function that I am trying to execute.

Option Explicit
Private Sub PriErrCod()
    Dim i As Integer
    Dim e
    Debug.Print "Here are the error codes ..."
    For i = 0 To 65535
        e = Error(i)
        If e <> "Application-defined or object-defined error" Then Debug.Print i & ": " & e
    Next i
End Sub

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The type Integer does not support such a high number. Use Long instead and it will work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading