Account Login  Username:  Password: 

Erl

by khairil anwar yusoff
Category: Debugging and Error Handling
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3 February 2021
Rating: (4 Votes)

Checking Where Errors Occurs

Assumes
not so many vb programmer realize the existance of Erl (error line) and some of them who used it alway get the value of 0. here is an example, (makes me remember my old gwbasic). you can put the line number at the beginning of visual basic code, but not the function/sub header. eg. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Const strModuleName = "Form1.frm" '//module or form or class Private Sub myButtonClick() On Error Goto errClick 12345 '//NOTICE, THIS IS THE LINE NUMBER, '// YOU CAN PUT WHATEVER NUMBER FORM UP TO 65535(max) Dim intX as Integer '//GENERATING RUNTIME ERROR intX = 12 \ 0 'Division by Zero Exit Sub errClick: '//Show what line number does Erl recently passed before error 'occurs MsgBox Err.Number & " - " & Err.Decription, , _ strModuleName & " - " &Erl End Sub This will pop up a message box "11 - Division by Zero" with title Form1.frm - 12345. Numbering every code line is tedious thing to do, some suggestion, just put UNIQUE number ID(plus some constant of your module/form/class Name) at the beginning of you critical function (function which error is likely to happen). so when error comes, you will know which function it came from

Rate Erl

Download Erl

Download Erl (3 KB)

Erl Comments

No comments have been posted about Erl. Why not be the first to post a comment about Erl.

Post your comment

Subject:
Message:

0/1000 characters