Does Anyone Know How To Label Or Number Lines Of VB Code

ThunderBolt

Registered User.
Local time
Today, 23:04
Joined
Apr 29, 2003
Messages
25
I need to number and anitate my Visual Basic Code so when it is printed off i can refer to specific parts of it easily eg. code on line 12 shows...
Does anyone know how to tackle this problem! Any feedback most welcome!!

Regards,

ThunderBolt :(
 
When typing code in VB, you can still use the nostalgic method of yesteryear.

Code:
Function Example()
10
20 On Error GoTo Err_Example
30
40 Dim strMessage As String
50 Dim strTitle As String
60
70 strMessage = "This is just an example."
80 strTitle = "Example"
90
100 MsgBox strMessage, vbInformation, strTitle
110
120 Exit_Example:
130     Exit Function
140
150 Err_Example:
160 MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
170     Resume Exit_Example
180

End Function
 
I like to use line numbers on what I call "sub-routines"

If x = y Then

GoTo 20

Else

Goto 30

End If

20: Sub-routine here

30: Another one here

Sometimes its useful to keep code in neat "chunks" (don't know if its the "proper" way):D

Col
 
GoTo is good if you want to jump about the code, for better structure you're better off to use the Gosub and Return statements as you can branch out to a subroutine and once it's done, use the Return statement to return to the exact position that initially called subroutine within the sub.
 
ColinEssex said:
If x = y Then

GoTo 20

Else

Goto 30

End If

20: Sub-routine here

30: Another one here

The danger with that is that if there is no other Goto 40 line before label 30 in that code then the code will run both actions if x = y.
 
Thanks Mile-O thats something I used to know but had forgotten about.

I'll write that in my little book (how sad:rolleyes: )

Col
 
Yes Mile-O - the line 20 routine would of course have an Exit Sub or some other method of jumping line 30.

Col
 
But can u number lines for refernce use only, each individual line in numerical order
1
2
3
4
5
6
7
8
9
 
Yes, except lines where you declare a sub or function.
 
hav u got to label them naually or is there a option that will display numbers for u?
 
o rite coz me m8s done his project in delphi and it does um automatically in that, ill just use the "rem" - ... thing to add sum notes and i good olf fashione dhighlighter pen! ta though, i spent ages lookin for an option to do it, at leats i kno now it cant be done automatically!
 

Users who are viewing this thread

Back
Top Bottom