is there any way to get the VB6 IDE to show line numbers ?
Printable View
is there any way to get the VB6 IDE to show line numbers ?
Not that I know of. What you have to do is number each line yourself. For example:
VB Code:
Private Sub Command1_Click() 1 HelloWorld End Sub Private Sub HelloWorld() 2 Dim a As String 3 Dim b As String 4 a = "Hello" 5 b = "World" 6 MsgBox a & " " & b End Sub
If you search around, I'm sure that somebody has developed an addin for the VB IDE to do this for you, but I don't know of a specific one. You might try www.searchvb.com as a start.
Why would you want them?
I would assume he wants them for Error Coding. They're not good for much else.
In my opinion they are not good for anything. Not only is GoTo 87 (and similar) a recipe for spaghetti code, but imagine the maintenance nightmare when adding and removing lines of code between the GoTo and line 87.
not for coding purposes.
its just that i when i am doing some debugging on the phone with a co-developer i constantly find myself saying things like:
"Look at strSQL in module A , sub B ... no not that one, the third one down from that ... blah blah"
Itd just be easier to say "Look at line 244 in module A"
Oh, in that case you and your co-developer want to install and use NetMeeting. It lets you both look at the same window and he can see where your mouse is pointing.
yah netmeeting is good, but id still like to be able talk effectively about code without having a network connection handy on both ends.
Thanks for the responses, btw ...
There is an addin "PrettyCode" something or other which allows you to print with line numbers, but nothing I have seen for within VB IDE. :(
look HERE
Thanks James,
That looks interesting ... Ill check it out.
;)
Martin:
Line numbering can be used for other err coding beside the "GoTo" statement. I use it as follows.
VB Code:
Private Sub Command1_Click() 1 HelloWorld End Sub Private Sub HelloWorld() 9 On Error GoTo ErrCode 2 Dim a As String 3 Dim b As String 7 Dim c As Integer 4 a = "Hello" 5 b = "World" 8 c = "String" 6 MsgBox a & " " & b Exit Sub ErrCode: MsgBox Err.Number & vbCrLf & Erl & vbCrLf & Err.Description End Sub
"Erl" will return the line number that generated the error. Also you said:
"but imagine the maintenance nightmare when adding and removing lines of code between the GoTo and line 87."
If you look at the above example, you do not have to re-number when you add or delete code. VB does not care if the line numbers are in order. Plus if you seperate your code into multiple subs and number the subs individualy, you can better keep track of your numbering. Just be sure that your error coding tells the user what sub the error occured in.
I think that says it all. Sure, putting line numbers on every line of code makes it a little easier to locate the line that is causing the problem, but in the real world programs have thousands (if not tens of thousands) of lines and I can't imagine using line numbers in that case.Quote:
...you can better keep track of your numbering.
Actually I was thinking of something more along the lines of the cursor position information in MSFT Word (ie Ln11). Does this exist in the IDE anywhere?
I really dont want to number thousands of lines of code even if I can find an add in to do it for me.
Sure. If you have the Standard toolbar showing, you'll see something like the following if you are editing code.
Ln 31, Col 7
doh!
cant believe i never saw that ...
:D
Thanks!
(Yes this is an old post. But it's one of the first to come up in Google when looking for information about this topic.)
It IS an old thread, and should be left as such. Advertising a commercial tool is not allowed, and since the tool you had mentioned no longer has a free version, I have removed it from the thread.