Upgrading from VB6 to V2005

Posted on 2006-04-03
Last Modified: 2013-11-13
I asked a question today about VB Express 2005 vs the professional version.  That question was:

I'm a VB6 programmer and want to learn VB 2005.  I have a CD with VB 2005 express.  Is it worth practising on Express or should I fork out for the professional Edition?
My next question is:

What can I do in Vb 2005 that I can't do in Vb6.  In VB6 I already have bits of code that I reuse as needed.  What practical difference can it make e.g. better API calls, a sorting algorithm, more functions for working with strings and dates...?
Question by:AlHal2
    LVL 44

    Accepted Solution

    1) with .NET, you should not need ANY API calls, except possibly to third party libraries - ALl of eht Microsoft APIs are already built into  the .NET Framework.

    2)  You will find that it is not so much what you can do with .NET that you can't do with VB^, but rather that the way you do it in .NET is many times VERY VERY different - you will need to re-learn a lot of what you have been doing with VB6.
       a) EVERYTING, repeat, EVERYTHING in .NET is an object, and thus has Properties and Methods.

           for example, a variable declared as String has a Replace METHOD, which serves to completely 'replace' the VB6 Replace FUNCTION:

          Dim MyString as String = "This is MY string"

          MyString.Replace ("MY", "John's")

          MyString now is "This is John's string"

         Integer variables have a ToString method, which can serve to format the resulting String (thus replacing the VB6 Format FUNCTION)

         Dim MyInt as Integer = 12345;

         MessageBox.Show( "The Value is " & MyInt.ToString("#,##0"))

    (this could also be doe as :

         MessageBox.Show("The Value is {0,"#,##0}", MyInt)

    Notice the NEW MessageBox function in .NET - which replaces the VB6 MsgBox.

    These are just a few of the significant differences.

    Please do yourself a BIG favor, and do NOT attempt to 'upgrade' your existing VB 6 code to .NET, using the UPGRADE Wizard - you will create far more work for yourself, trying to fix the 'errors' that will be reported with the 'upgrade' , which will require far more time to fix, that you would spend, re-wrtiting the functionality of the VB6 code, in 'proper' .NET, to begin with.  

    I would strongly advise you to forget EVERYTHING - well, almost EVERYTHING, since the Syntax of VB.NET is quite similar to the Syntax of VB.NET, but that is about as far as the similarities go - that you ever thought you knew about VB, because the sooner you do that, and adapt to the VB.NET way of doing things, the better.  VB.NET is a PURE Object Oriented language, where VB6 was 'Object Based' - and there is a huge differencve between them, simply because of that distinction.  VB.NET is not simply a 'better' version of VB6.  It is a completely DIFFERENT animal.

    LVL 14

    Assisted Solution

    In general, .NET versions of Visual Basic (2002, 2003, 2005), have the following advantages over VB 6.0:

    1. A *very* rich class library (the same class library accessible from C# and C++ .NET).
    2. Direct interoperability with components created using other .NET languages.
    3. Enhanced versions of components/technologies (such as ADO .NET and ASP .NET).
    4. Portability to other platforms running the .NET Framework (other Windows/non-Windows operating systems, Pocket PC's, etc...). Porting the .NET Framework to non-Windows operating systems has not been achieved yet.
    5. You get the full-featured compiler for free (it gets installed with the .NET Framework). Visual Studio 2005 even has free versions of the IDE's (Express Editions).

    As for your other question, the Express Edition is just a limited "Integrated Development Environment". It provides less development "facilities" (yet already very powerful) than other versions of Visual Studio. However, the compiler is the same, and the available laguage API's are also the same, etc...

    In brief, you can develop powerful VB .NET applications using the Notepad, and the command line compiler!! So take advantage of the freely available Express Edition to explore the .NET environment.


      Nayer Naguib
    LVL 14

    Expert Comment

    I suggest that you take a while writing miscellaneous VB .NET applications before you start upgrading your VB 6.0 code to VB .NET. Although both are *very* easy to program, you need to be familiar with .NET programming before you start upgrading your old code. This is because you will not be modifying your code on a line-by-line basis. For example, you may have 10's of lines of VB 6.0 code that would be translated to a single method call to an object of some existing class in the .NET Framework Class Library.


      Nayer Naguib
    LVL 14

    Expert Comment

    The .NET Framework does *not* encapsulate *every* existing Win32 API call, just the most frequently used by programmers.
    For example, to set the transparency of a form in .NET, you just write something like this:

      myForm.Opacity=0.x 'where x is the percentage of opacity

    But to register your application as an application desktop toolbar (a form that will dock to some edge of the screen and shrink the desktop), you still need to call Windows API's.


      Nayer Naguib

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    This article will show, step by step, how to integrate R code into a R Sweave document
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now