Solved

Visual basic does not use line numbers as Fortran

Posted on 2003-12-09
7
247 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 50 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
message box in access 4 51
VBA: Select SQL query based on a config Sheet v2 11 49
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 56
Authentication of Web Services 3 89
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

808 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