Link to home
Start Free TrialLog in
Avatar of gonzal13
gonzal13Flag for United States of America

asked on

Visual basic does not use line numbers as Fortran

I am new at using visual basic. What I want to do is translate 25,000 lines of code that I did many years ago in Darthmoth Basic and update the program. Now Darthmouth basic uses line numbers where as MS Visual Basic does not. Is thare a way to refer to a line of code in a for else do loop, etc?

gonzal13(Joe)
Avatar of leonstryker
leonstryker
Flag of United States of America image

You can create a label and the refer to it like:

Sub Test()
    GoTo LABEL
    Msgbox "Before"
LABEL:
    Msgbox "After"
End Sub

But, you should really think about recoding the methodaloggy of the program and utilize object oriented structures.

Leon
VB still understands line numbers and you can jump around to them using the GoTo statement.
ASKER CERTIFIED SOLUTION
Avatar of dasari
dasari

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
With numbers, you don't even need the colon afterwards.  That is reserved for alpha labels.
Avatar of gonzal13

ASKER

dasari


Thanks for your answer. You were the only one that provided the syntax

Gonzal13(Joe)
A : symbol in VB designates an end of a line and the begining of the next one.  Technically you can write your code like this

Sub Test()
Dim x, y, z: x = 1: y = 2: z = 1: If y = 2 Then MsgBox x + x + y * y - z
End Sub

BTW, I think this question should have been a split at best.

Leon
Okay:

I am sure that splitting the points would be Ok although the amound is very low and already has been awarded before your comment came in. Therefore, I shall leave everything as they are.

I think I shall get another book on Visual Basic. The one I have, is very basic and does cover my needs.



gonzal13 (Joe)