Results 1 to 3 of 3
  1. #1
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed

    VB6 - VB.net Syntax Coversions

    VB6 - VB.NET Syntax Conversions
    (Part 1)

    If you're one of those guys/girls who have that old VB6 code just lying around and would like to migrate over to vb.net without rewriting everything from scratch... then this article should (could) help...

    Well written code converts easy

    First thing in any conversion (even in converting borland C to VC++ or similiar) is to clean up and make your code as functional and "simple" as possble"

    Before converting , you should use a "clean up" concept and be sure to

    • Notate the important functionality s of your code using 'Your notes(this will allow you to find code that may have experienced a significant change)
    • Declare every single variable.
    • make sure all variables have the explicit type (as opposed to variants.)
    • Check timers, be sure to set timer1.enabled = false (as opposed to the alternative in vb6 which allowed you to set it to 0 )
    • Convert DAO and RDO to ADO.


    Consider the following a reference guide, somewhere you can come when you need to migrate your VB6 project to VB.NET

    Errors

    (check out my errors article)
    Handle Your Errors

    In VB6
    On Error Goto errhandler

    __________(code..yada...yada...)

    errhandler:
    MsgBox(err.Description)

    In VB.NET

    Try

    Throw New Exception("error description")

    Catch e as Exception
    MsgBox(e.Description)
    End Try

    Events

    Handling an event

    In VB.NET,you can us the new keyword AddHandler.

    AddHandler object.event, AddressOf procedure

    DoEvents

    VB6
    DoEvents

    VB.NET
    System.Windows.Forms.Application.DoEvents

    App Object

    Full Filepath

    VB6
    App.Path & App.EXEName

    VB.NET

    System.Reflection.Assembly.GetExecutingAssembly.Lo cation.ToString

    App instance

    VB6

    App.hInstance

    VB.NET
    System.Runtime.InteropServices.Marshal.GetHINSTANC E _(System.Reflection.Assembly.GetExecutingAssembly. GetModules() _(0)).ToInt32()

    Previous Application Instance

    VB6
    App.PrevInstance

    VB.NET
    Function PrevInstance() As Boolean
    If Ubound(Diagnostics.Process.GetProcessesByName(Diag nostics.Process.GetCurrentProcess).ProcessName)) > 0 Then
    Return True
    Else
    Return False
    End If

    End Sub

    Graphics

    Load Picture

    VB6
    Picture1.Picture = LoadPicture(path)

    VB.NET
    Dim imgf As Image = Image.FromFile(path)
    Picture1.Image = imgf

    Load icons

    VB6
    Me.Icon = LoadPicture(path)

    VB.NET
    Dim icof As New Icon(path)
    Me.Icon = icof

    File I/0

    Read File

    VB6
    Open path For Input As #1
    Line Input #1, buffer
    Close #1

    VB.NET
    Dim fst As FileStream = File.Open(path, FileMode.OpenOrCreate, _ FileAccess.Read)
    Dim srf As New StreamReader(fst)
    Buffer = srf.ReadLine
    srf.Close

    Write in a file

    VB6
    Open path For Output As #1
    Write #1, buffer
    Close #1

    VB.NET
    Dim fst As FileStream = File.Open(path, FileMode.OpenOrCreate, _
    FileAccess.Write)
    Dim srw As New StreamWriter(fst)
    srw.Write(buffer)
    srw.Close

    Note: This again is a reference guide, so if your new to vb.net and used vb6 in the past and are looking to make the transistion, start here.


    Hope this helps
    Last edited by NextGen1; 01-21-2010 at 01:35 PM.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  2. The Following 3 Users Say Thank You to NextGen1 For This Useful Post:

    Hell_Demon (01-21-2010),Lolland (01-21-2010),XGelite (01-21-2010)

  3. #2
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,977
    Reputation
    343
    Thanks
    4,324
    My Mood
    Cheeky
    Gj
    Last edited by Pixie; 01-21-2010 at 05:14 PM.
    Ah we-a blaze the fyah, make it bun dem!

  4. #3
    XGelite's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Enter text here
    Posts
    1,344
    Reputation
    12
    Thanks
    276
    this is nice. Thanks a lot

Similar Threads

  1. [Help]Convert VB6 code to VB.NET[Solved]
    By nathanael890 in forum Visual Basic Programming
    Replies: 13
    Last Post: 08-07-2010, 12:11 AM
  2. HackShardGaming.net says Fuck MPGH
    By sf0d in forum General
    Replies: 32
    Last Post: 07-26-2006, 09:05 PM
  3. [Help] Atom API with Visual Basic 6.0 or .NET
    By Bull3t in forum Visual Basic Programming
    Replies: 5
    Last Post: 07-23-2006, 09:21 AM
  4. Me r MAD.. GONNA DDOS WarRock.net :)
    By System79 in forum WarRock - International Hacks
    Replies: 14
    Last Post: 06-19-2006, 05:06 PM
  5. Gangsterhood.net
    By supatanka in forum Hack Requests
    Replies: 0
    Last Post: 01-22-2006, 01:42 PM