All source code in .Net Ask a .Net Pro Discussion Forum Categories All jobs in .Net
VB6,VBNET,tutorial,teaches,syntax,migration,f
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
.Net Stats

 Code: 666,891. lines
 Jobs: 818. postings

 How to support the site

 
Sponsored by:
Quick Search for:  in language:    
You are in:
 
Login





Latest postings for .Net.
SQL Backup/Restore using SMO
By Visual Soft Computers on 2/6


Click here to see a screenshot of this code!flexi grid
By maytel.mynt on 1/12

(Screen Shot)

Using Excel in VB2010 (VB10)
By Alberto Torres on 2/5


Click here to see a screenshot of this code!SermonNotes
By arifliminto86 on 2/5

(Screen Shot)

Click here to see a screenshot of this code!A.net Programm to add new database
By Rohit Kanugo on 2/5

(Screen Shot)

Access_Database _Add
By Rohit Kanugo on 2/4


Add new DataBase Through Coding for a IT Company
By Rohit Kanugo on 2/4


Click here to see a screenshot of this code!Numbert To Word Conversion Short and Simple Code
By Opal Raj Ghimire on 2/3

(Screen Shot)

Click here to see a screenshot of this code!Monopoly Game
By arifliminto86 on 2/1

(Screen Shot)

Click here to see a screenshot of this code!Write Text to File, Write Binary To File
By brandon teoh on 2/1

(Screen Shot)

Click here to see a screenshot of this code!Movable Resizable Runtime Controls VB2005 Version
By SC Project on 2/1

(Screen Shot)

Desktop Email Client
By Avinash Kumar Sharma on 1/30


Website Source Code Grabber
By Avinash Kumar Sharma on 1/30


Click here to see a screenshot of this code!Auto Scrolling Label Method (autoscrolling textbox)
By Kenny28 on 1/30

(Screen Shot)

EL-Bandido Time Monitoring System Daily Record
By Ian Formanes on 1/30


Click here to see a screenshot of this code!Weather
By Jsvnascar on 1/29

(Screen Shot)

Mini NetMeeting
By Ian Formanes on 1/28


EL-Bandido
By Ian Formanes on 1/27


Click here to see a screenshot of this code!RegionMaker
By silviu petre on 1/27

(Screen Shot)

calculations class
By silviu petre on 1/26


Click here to see a screenshot of this code!Introduction to ADO.NET(OLEDBCO NNECTION)
By jay celeste on 1/21

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

Tutorial: How Do I Do It In VB.NET??

Print
Email
 
article
Submitted on: 4/13/2002 4:22:46 PM
By: Sean Dittmar 
Level: Beginner
User Rating: By 28 Users
Compatibility:VB.NET

Users have accessed this article 92090 times.
 
author picture
 
     This tutorial teaches syntax migration from VB6 to VB.NET with simple VB7/VB.NET comparison.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
Tutorial: How do I do it in VB.NET?
 
This tutorial explain some of the more common migrating problems from VB to VB.NET.
 
  • DoEvents

    VB6
    DoEvents

    VB7 
    System.Windows.Forms.Application.DoEvents
  • App Object

    Get the full application filepath

    VB6 
    App.Path & App.EXEName

    VB7 System.Reflection.Assembly.GetExecutingAssembly.Location.ToString

    Get the app's instance

    VB6 App.hInstance

    VB7
    System.Runtime.InteropServices.Marshal.GetHINSTANCE _(System.Reflection.Assembly.GetExecutingAssembly.GetModules() _(0)).ToInt32()

    Check for a previous instance

    VB6 
    App.PrevInstance

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

    End Sub
  • Graphics

    Load a picture

    VB6 
    Picture1.Picture = LoadPicture(path)

    VB7 
    Dim img As Image = Image.FromFile(path)
    Picture1.Image = img

    Load a icon

    VB6
    Me.Icon = LoadPicture(path)

    VB7
    Dim ico As New Icon(path)
    Me.Icon = ico

  • File I/0

    Read from a file

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

    VB7
    Dim fs As FileStream = File.Open(path, FileMode.OpenOrCreate, _ FileAccess.Read)
    Dim sr As New StreamReader(fs)
    Buffer = sr.ReadLine
    sr.Close

    Write to a file

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


    VB7
    Dim fs As FileStream = File.Open(path, FileMode.OpenOrCreate, _
    FileAccess.Write)
    Dim sr As New StreamWriter(fs)
    sr.Write(buffer)
    sr.Close

  • Errors

    Check for an error


    VB6
    On Error Goto errhandler
    ...
    errhandler:
    MsgBox(err.Description)

    VB7
    Try
         ...
         Throw New Exception("error description goes here")
         ...
    Catch e as Exception
         MsgBox(e.Description)
    End Try

  • Events

    Handling an event

    In VB7, there is a new keyword called AddHandler. AddHandler makes handling events a snap.

    AddHandler object.event, AddressOf procedure


Other 5 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this article(in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
4/15/2002 12:17:53 AMroswellevent

Great Tutorial
5 from me :)
(If this comment was disrespectful, please report it.)

 
4/15/2002 5:49:41 AMDave Lambert

Excellent stuff, but why .NET has to be so obscure is beyond me. I can see us all writing wrapper classes for the next n months to simplify the syntax back to something memorable and to what it should have been in the first place... 8-(
(If this comment was disrespectful, please report it.)

 
4/29/2002 11:13:58 AMSam Moses

Looks interesting.
I'm still not clear on the difference in syntax though. It seems to me that this .NET code could be just as simple as the vb6 code without much real change in the mothod.
(If this comment was disrespectful, please report it.)

 
5/1/2002 9:39:04 PMSlider

To understand why, you must look at the bigger picture - platform & OS indepentancy. This will mean that in the fututre, your application won't be tied just to 32-bit Intel platform & Windows OS. I've written a wrapper class to handle all VB7 'oddities' and am adding functions to them. Sean, great tutorial for those who need it! Keep them coming...
(If this comment was disrespectful, please report it.)

 
5/16/2002 1:51:28 PMPheonix

In VB6 I can do the following: picVideo.width = frmMain.width

How would I do that in VB.Net?
(If this comment was disrespectful, please report it.)

 
7/8/2002 2:01:42 AMtrance

the syntax seems very similar to java, except for the ';'s
(If this comment was disrespectful, please report it.)

 
7/12/2002 2:46:48 PMJohnB

In looking at this, it seems to me that VB.NET actually will take more time to code than VB6. Point in case: App.Path & App.EXEName VS. System.Reflection.Assembly.GetExecutingAssembly.Location.ToString Looks to me like MS wants you to get carpel tunnel syndrome... ;) Thanks for the info though!!!
(If this comment was disrespectful, please report it.)

 
8/28/2002 12:11:47 PMDhaval Faria

hey.. that was gr8.. but I need some diffrent help.. can u help me? please.. I need help badly.. but its easy.. but I am not getting it.. 5 globes from me..
(If this comment was disrespectful, please report it.)

 
9/23/2002 2:22:18 AM

great job....keep it coming along..
(If this comment was disrespectful, please report it.)

 
1/18/2003 4:20:30 PMVBGOD

Clean...
(If this comment was disrespectful, please report it.)

 
1/31/2003 2:26:45 AM

Good Show..
(If this comment was disrespectful, please report it.)

 
5/6/2003 5:16:39 AM

Why it seems that VB.net is more difficult to code? I mean it takes longer code than the old VB.
(If this comment was disrespectful, please report it.)

 
5/29/2003 9:48:31 PM

I just got my hands on .NET, I need to catch up... Excellent head start for VB6 programmers
(If this comment was disrespectful, please report it.)

 
7/4/2003 4:24:40 AMDeepak Kumar Shaw

It's really talking...
compect and to the point..
5 from me, good work!
(If this comment was disrespectful, please report it.)

 
7/13/2003 3:15:21 PM

im new to vb.net

how about Time() and Date() functions?
i want to create a clock like the one displayed in the taskbar.
thanks.
(If this comment was disrespectful, please report it.)

 
11/6/2003 5:30:05 PM

how about app.version ???
(If this comment was disrespectful, please report it.)

 
7/14/2004 6:23:48 AM

You did very well!
with all those coding differences,what is the best way to catch up.how do i resolve confusions..
(If this comment was disrespectful, please report it.)

 
1/21/2005 1:01:34 AMTony

nice work.. is there something out there to simlify these? and or maybe a larger file with more of these? i just got my hands on .net man.. i feel newbie all over.. it has been a few years since ive touched vb6 but wow.. this is painful! .. i look at it and almost want to not even try :O .. crawls back to his safety vb6 blanket.
(If this comment was disrespectful, please report it.)

 
3/26/2005 1:58:14 PMkunnu

good
(If this comment was disrespectful, please report it.)

 
7/11/2005 9:54:48 PMHong Thang

Please tell me how to know which causes a form to be closed in VB.NET. (In VB6, I use UnloadMode in event form_QueryUnload to determine)
Thanks.
(If this comment was disrespectful, please report it.)

 
11/18/2005 6:16:45 PMSoorya

Excellent comparison bet VB6 and VB7
Write more...
thanks
(If this comment was disrespectful, please report it.)

 
12/27/2006 3:39:20 PMDreamcoding

This is what we all need. Please post more VB 6 --> VB.NET code equivalents.
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Games | Feedback | Customize | .Net Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2010 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.