Domanda

I remember being a kid in the 1980s and numbering lines in BASIC because you had to. Nowadays, as far as I knew, numbered lines were 100% out; no one wants or needs to use them. That's until I discovered some legacy code I needed to work on. Every function has its lines numbered in increments of 10. My question is, are there any negative ramifications to using a mix of numbered and unnumbered lines? For example, if I'm modifying a function, can I just remove all the numbering from that function only without having any problems? I really don't feel like trying to maintain such an arcane system if I don't need to, but I also don't think there's any major benefit to clearing out all the numbering for the entire project.

È stato utile?

Soluzione

To the best of my knowledge, line numbers in VB6 are only helpful for error handling. Something like this:

Private Sub Command1_Click()

    Dim i As Long

    On Error GoTo ErrorHandler

10:     i = 20
20:     i = i / 2
30:     i = i / 0

    Exit Sub

ErrorHandler:

    MsgBox ("Error on line: " & Erl)

End Sub

When you run this code, it will say "Error on line 30". There is a free tool for VB6 called MZ Tools that is a plug in for VB6. This tool can add/remove line numbers as well as insert error handling for you. I encourage you to take a look at it.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top