Welcome to Dream.In.Code
Become a VB Expert!

Join 150,134 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,221 people online right now. Registration is fast and FREE... Join Now!




Convert VB6 code to VB.NET

 
Reply to this topicStart new topic

Convert VB6 code to VB.NET, Trying to convert VB6 code to VB 2008 Express Edition.

edwardelric
13 Jul, 2008 - 12:51 PM
Post #1

New D.I.C Head
*

Joined: 13 Jul, 2008
Posts: 2

I was wondering if there is anyone who can convert this for me, I used VB6 in College but now as its not available I cant look at my program.

I hope someone can help thank you.

vb

Option Explicit On
Dim sngAngle As Single
Dim sngH As Single
Dim sngX As Single
Dim sngY As Single
Dim intAttempts As Integer

Private Sub cmdGo_Click()
If txtDistance = "" Then
intAttempts = intAttempts
MsgBox("Please enter a distance")
Else
intAttempts = intAttempts + 1
End If
If txtBearing = "" Then
intAttempts = 0
MsgBox("Please enter a bearing!")
End If
sngAngle = Val(txtBearing)
sngAngle = sngAngle * 3.1415 / 180
sngH = Val(txtDistance)
sngX = sngH * Sin(sngAngle) / 10
sngY = sngH * Cos(sngAngle) / 10
imgHecilopter.Left = imgHecilopter.Left + sngH * Sin(sngAngle)
imgHecilopter.Top = imgHecilopter.Top - sngH * Cos(sngAngle)
lblAttempts = intAttempts
If txtFuel = "0" Then
MsgBox("Mission Failed")
Timer1.Enabled = False
End If
End Sub

Private Sub Exit_Click()
If Confirm("Are you sure you want to exit?", "Exit") = vbYes Then
End
End If
End Sub

Private Sub Form_Load()
imgInjured.Left = Int(Rnd * Frame4.Width)
imgInjured.Top = Int(Rnd * Frame4.Height)
Randomize()
End Sub

Private Sub NewGame_Click()
If Confirm("Are you sure you want to start a new game?", "New Game") = vbYes Then
Call Form_Load()
End If
End Sub

Private Sub About_Click()
frmAbout.Show()
End Sub

Private Sub Back_Click()
If Confirm("Are you sure you want to exit?", "Exit") = vbYes Then
frmMain.Show()
End If
Unload(Me)
End Sub

Private Function Confirm(ByVal strConfirm As String, ByVal strTitle As String) As Integer
Confirm = MsgBox(strConfirm, vbYesNo, strTitle)
End Function

Private Sub Timer1_Timer()
txtFuel = txtFuel - 1
End Sub

Mod edit: Please code.gif
Thanks, gabehabe smile.gif
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Convert VB6 Code To VB.NET
13 Jul, 2008 - 02:59 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Unfortunately no one will just convert this code for you, thats not what what we're here for at Dream.In.Code. We will, however, help you as you walk through the conversion process yourself smile.gif
User is offlineProfile CardPM
+Quote Post

jacobjordan
RE: Convert VB6 Code To VB.NET
13 Jul, 2008 - 04:38 PM
Post #3

class Me : Perfection
Group Icon

Joined: 11 Jun, 2008
Posts: 1,262



Thanked: 39 times
Dream Kudos: 1675
My Contributions
Sorry to go against your philosophy Psycho, but it really wasn't that hard

vb

Dim sngAngle As Single
Dim sngH As Single
Dim sngX As Single
Dim sngY As Single
Dim intAttempts As Integer

Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles cmdGo.Click
If txtDistance = "" Then
intAttempts = intAttempts
MsgBox("Please enter a distance")
Else
intAttempts = intAttempts + 1
End If
If txtBearing = "" Then
intAttempts = 0
MsgBox("Please enter a bearing!")
End If
sngAngle = Val(txtBearing)
sngAngle = sngAngle * 3.1415 / 180
sngH = Val(txtDistance)
sngX = sngH * Math.Sin(sngAngle) / 10
sngY = sngH * Math.Cos(sngAngle) / 10
imgHecilopter.Left = imgHecilopter.Left + sngH * Math.Sin(sngAngle)
imgHecilopter.Top = imgHecilopter.Top - sngH * Math.Cos(sngAngle)
lblAttempts = intAttempts
If txtFuel = "0" Then
MsgBox("Mission Failed")
Timer1.Enabled = False
End If
End Sub

Private Sub Exit_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles [Exit].Click
If Confirm("Are you sure you want to exit?", "Exit") = vbYes Then
End
End If
End Sub

Private Sub Form_Load(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Load
imgInjured.Left = Int(Rnd() * Frame4.Width)
imgInjured.Top = Int(Rnd() * Frame4.Height)
Randomize()
End Sub

Private Sub NewGame_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles NewGame.Click
If Confirm("Are you sure you want to start a new game?", "New Game") = vbYes Then
Form_Load(Me, New EventArgs())
End If
End Sub

Private Sub About_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles About.Click
frmAbout.Show()
End Sub

Private Sub Back_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles Back.Click
If Confirm("Are you sure you want to exit?", "Exit") = vbYes Then
frmMain.Show()
End If
Me.Close()
End Sub

Private Function Confirm(ByVal strConfirm As String, ByVal strTitle As String) As Integer
Confirm = MsgBox(strConfirm, vbYesNo, strTitle)
End Function

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As EventArgs) Handles Timer1.Tick
txtFuel -= 1
End Sub

Also, you didn't explain some things, so you might need to edit this code a bit more.
User is offlineProfile CardPM
+Quote Post

edwardelric
RE: Convert VB6 Code To VB.NET
14 Jul, 2008 - 07:13 AM
Post #4

New D.I.C Head
*

Joined: 13 Jul, 2008
Posts: 2

Thanks for the help smile.gif It seems to work ok and I see some of the places where I need to modify, hopefully I can make it as functional as it was before and update smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 01:55AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month