Solved

Visual basic does not use line numbers as Fortran

Posted on 2003-12-09
7
244 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

758 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

18 Experts available now in Live!

Get 1:1 Help Now