Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Visual basic does not use line numbers as Fortran

Posted on 2003-12-09
7
Medium Priority
?
257 Views
Last Modified: 2013-11-25
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)
0
Comment
Question by:gonzal13
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 9906489
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
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 9906714
VB still understands line numbers and you can jump around to them using the GoTo statement.
0
 
LVL 4

Accepted Solution

by:
dasari earned 200 total points
ID: 9906831
I don't know about basic but u can something like this in VB as suggested above......the numbers here are actually labels and u can use  GOTO 2 or any line using labels.....

Example.....

Private Sub Command3_Click()
1: Dim Db
2: Dim Rs
3: Set Db = CurrentDb()
4: Set Rs = Db.OpenRecordset("SELECT * FROM TABLENAME")
5:
6: Rs.AddNew
7: Rs(0) = "XXX"
8: Rs(1) = "YYY"
9: Rs.Update
10:
11: Set Rs = Nothing
12: Set Db = Nothing
13:
End Sub
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:AzraSound
ID: 9906887
With numbers, you don't even need the colon afterwards.  That is reserved for alpha labels.
0
 
LVL 13

Author Comment

by:gonzal13
ID: 9906903
dasari


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

Gonzal13(Joe)
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 9906971
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
0
 
LVL 13

Author Comment

by:gonzal13
ID: 9907819
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)
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question