Converting VB 5/6 to VB.net

avensus

New member
Joined
Mar 6, 2006
Messages
4
Programming Experience
Beginner
Can anyone help me do the conversion of a piece of code to vb.net? Would really appreciate as i'm so cut for time. Cheers. :eek:

Option Explicit
Dim flight(1 To 10, 1 To 4) As String
Dim waiting(1 To 50) As String
Dim waitinglist As Integer
Private Sub cmdAddToFlight_Click()
Dim person As String, a As Integer, b As Integer
person = Trim(txtPerson.Text)
person = Left(UCase(person), 1) + Mid(person, 2)
For a = 1 To 10
For b = 1 To 4
If UCase(person) = UCase(flight(a, b)) Then
MsgBox "The person you entered is already on the list"
Exit Sub
End If
Next b
Next a
a = Val(InputBox("Which row does this person want?", "Row"))
If a > 10 Or a <= 0 Then
MsgBox "I am sorry, but there is no row assigned to that number"
Exit Sub
End If
b = Val(InputBox("Which seat does this person want?", "Seat"))
If b > 4 Or b <= 0 Then
MsgBox "I am sorry, but there is no seat assigned to that number"
Exit Sub
End If
flight(a, b) = person
Call cmdShow_Click
End Sub
Private Sub cmdAddWaitingList_Click()
Dim person As String, a As Integer
person = Trim(txtPerson.Text)
person = Left(UCase(person), 1) + Mid(person, 2)
If waitinglist > 0 Then
For a = 1 To waitinglist
If UCase(person) = UCase(waiting(a)) Then
MsgBox "The person you just entered is already on the list"
Exit Sub
End If
Next a
End If
waitinglist = waitinglist + 1
waiting(waitinglist) = person
Call cmdWaiting_Click
End Sub
Private Sub cmdEnd_Click()
End
End Sub
Private Sub cmdRemoveFromTheFlight_Click()
Dim a As Integer, b As Integer, person As String
Dim answer As String, c As Integer
person = Trim(txtPerson.Text)
person = Left(UCase(person), 1) + Mid(person, 2)
For a = 1 To 10
For b = 1 To 4
If UCase(person) = UCase(flight(a, b)) Then
answer = InputBox("Are you sure you want to delete this person from the passenger list (Y/N)")
If UCase(Left(answer, 1)) = "Y" Then
flight(a, b) = waiting(1)
For c = 1 To waitinglist
waiting(c) = waiting(c + 1)
Next c
waitinglist = waitinglist - 1
Call cmdWaiting_Click
Call cmdShow_Click
Else
Exit Sub
End If
End If
Next b
Next a
End Sub
Private Sub cmdRemoveFromTheWaitingList_Click()
Dim person As String, a As Single, b As Integer
person = Trim(txtPerson.Text)
person = Left(UCase(person), 1) + Mid(person, 2)
For b = 1 To waitinglist
If (UCase(person) = UCase(waiting(b))) Then
For a = b To waitinglist
waiting(a) = waiting(a + 1)
Next a
waitinglist = waitinglist - 1
Call cmdWaiting_Click
Exit Sub
End If
Next b
Call cmdWaiting_Click
End Sub
Private Sub cmdShow_Click()
Dim a As Integer, b As Integer
picFlight.Cls
For a = 1 To 10
For b = 1 To 4
picFlight.Print flight(a, b),
Next b
picFlight.Print
Next a
End Sub
Private Sub cmdWaiting_Click()
Dim a As Integer
picWaiting.Cls
If waitinglist = 0 Then
picWaiting.Print "There is no-one on the"
picWaiting.Print Tab(13); "waiting list"
End If
For a = 1 To waitinglist
picWaiting.Print a; ": "; waiting(a)
Next a
End Sub
Private Sub Form_Load()
Dim a As Integer, b As Integer
For a = 1 To 10
For b = 1 To 4
flight(a, b) = 0
Next b
Next a
End Sub
 
Hello avensus, there is upgrade wizard in VS2003 when you open a VB6 project there. Also if you only want to upgrade some code snippet, then there is a tool from main menu Tools -> 'upgrade vb6 code'
For basic means it is beneficial, but there are limitations of course. (I think it is improved in new VS2005) You will probably get some warnings, in other cases some code just have to be rewritten to native .Net language.

Here is some reference http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconupgradingapplicationscreatedinpreviousversionsofvisualbasic.asp

I would also strongly recommend to start new projects and write all new code in .Net for your old projects if you got time, since much has changed, and this is also a good opportunity to learn while working on familiar projects.

One tip also, use the editor tools here when posting, for instance to put your code in code boxes for better readability.
 
JohnH said:
Hello avensus, there is upgrade wizard in VS2003 when you open a VB6 project there. Also if you only want to upgrade some code snippet, then there is a tool from main menu Tools -> 'upgrade vb6 code'
For basic means it is beneficial, but there are limitations of course. (I think it is improved in new VS2005) You will probably get some warnings, in other cases some code just have to be rewritten to native .Net language.

Here is some reference http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconupgradingapplicationscreatedinpreviousversionsofvisualbasic.asp

I would also strongly recommend to start new projects and write all new code in .Net for your old projects if you got time, since much has changed, and this is also a good opportunity to learn while working on familiar projects.

One tip also, use the editor tools here when posting, for instance to put your code in code boxes for better readability.

Cheers John, appreciate it. I hope I'm not pushing it but would you mind putting the conversion here? Thanks again. Basically the reason I need this in .net is so that I can gain an understanding of it by playing around with it. I should then be able to learn more and build some new code. I feel so distracted :(
 
Last edited by a moderator:
I see no reason why I should do that, really. You got the tools and the descriptions, it's just a matter of a few clicks and you're there.
 
You should help me because I asked if you could. I'm new at this and still in a learning stage. Never mind, a simple no is fine because I've already tried it and had some errors saying problem in translation hence I asked.
 
I did. Besides, your project includes controls that need to upgrade too, not only code, the pictureboxes and command buttons in the code you first pasted for instance.
 
avensus said:
You should help me because I asked if you could. I'm new at this and still in a learning stage. Never mind, a simple no is fine because I've already tried it and had some errors saying problem in translation hence I asked.
Asking people to translate an entire chunk of code like that is one thing, asking for help on a few lines is another. You never mentioned that you already tried to convert it and got errors.

Step one: Open VS.NET and select Open Project. Find your VB6 project file and open it.

Step Two: Run it through the conversion.

Step Three: LOOK at the Task List, and the code. There will be a number of things the conversion will have marked as things that need to be done.

Step Four: Modify what you can.

Step Five: Ask here or some where else about converting SPECIFIC lines. Show the code, and note what you get and what you don't get. But don't ask for EVERYTHING to be converted.

Step Six: Be prepared to be patient. Not all of us keep everything in our heads and something may need to be looked up.

Step Seven: Be prepared to learn. It's quite possible that what you get as a response isn't the converted code, but links to references that will have the info you need to learn in order to convert the code yourself.

-tg
 
avensus said:
You should help me because I asked if you could. I'm new at this and still in a learning stage. Never mind, a simple no is fine because I've already tried it and had some errors saying problem in translation hence I asked.

Should help....!?!!
Because i asked if you could....!?!!

JohnH, could you get me a biscuit!?!!:D
 
Answering questions is voluntary for all registered forum users. avensus is entitled to ask, and I think some pretty decent answers were given to the problem in question.
 
Re:

It should not be very difficult to to upgrade this program to a completely functional .NET program it may help you if you are going to be doing this things often to go out and get a quick reference guide for VB.NET because you can import this code with few errors and have it working but some of the functions it seems like they are trying to get away from. Like UCase is now part of any string object and you can simply put .ToUpper and it will return the same thing. I am a fairly new .NET developer and sometimes it helps to hear from someone at the same skill level as you. Do not get frustrated and you will never learn if you just have someone convert it for you and say here it is. Here is what i suggest.

Do everything that the person above me listed and buy a quick reference guide for .NET. They may even have a quick reference for conversion of VB6 im not really sure. But if you understand what you are trying to accomplish with the help you can obtain on here and in a reference manual you should be able to learn and accomplish what you need. GOOD LUCK!!!!!
 
Back
Top