Solved

Visual basic does not use line numbers as Fortran

Posted on 2003-12-09
7
245 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now