?
Solved

Visual basic does not use line numbers as Fortran

Posted on 2003-12-09
7
Medium Priority
?
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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 SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses

719 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