Showing Line numbers in code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following shows me the last line number executed. It requires an error.

7811: Try
Err.Raise(60000)
Catch ex As Exception
MsgBox("Error 60000 at " & Err.Erl())
End Try

Is there a way to show a line number without creating an error. For
example, I am looking for a function that would return the following message:

"You just executed a statement at line #7811"

7811: If X = 2 Then
MsgBox "You just executed a statement at #" & ????
End IF

I can't find this function or figure out how to write it. Is there a way to
do this?
 
genojoe said:
"You just executed a statement at line #7811"

7811: If X = 2 Then
MsgBox "You just executed a statement at #" & ????
End IF

I can't find this function or figure out how to write it. Is there a way
to
do this?

AFAIK, no.
 
If you are using the Debug version (that is, you generate a .pdb file) the
closest that I can think is:

Dim objStackFrame As StackFrame
Dim x As Integer

If x = 0 Then
objStackFrame = New StackFrame(True)
MessageBox.Show("You have executed line " &
(objStackFrame.GetFileLineNumber() - 1).ToString)
End If

And then you can display line numbers in the code using the Tools, Options
menu, Text Editor, Basic, General node, Display Line Numbers checkbox.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top