Converting .bas files from VB 6.0 to VB.NET Project

Last post 11-04-2009 2:55 PM by atconway. 2 replies.

Sort Posts:

  • Converting .bas files from VB 6.0 to VB.NET Project

    11-04-2009, 9:01 AM
    • Member
      point Member
    • ankurr
    • Member since 10-07-2009, 7:51 AM
    • Posts 10

    I have my project in which i have many .bas files and now i want to convert the project into VB.NET. The vbp files are directly converted by Visual Studio 2005 but .bas files are not being converted. Could u please suggest.

  • Re: Converting .bas files from VB 6.0 to VB.NET Project

    11-04-2009, 9:29 AM
    • Star
      8,840 point Star
    • integrasol
    • Member since 06-05-2009, 11:18 AM
    • Denmark & Spain
    • Posts 1,642

    It's been a while since I last worked on a VB6 project, but in general the code in the .bas files should be moved to Modules or class files in VB .NET. Mind you, you will need to do a fair bit of conversion when doing so. 

    Thanks

    Carsten

    Please click Mark as Answer if this post is of help to you. :-)



    My Blog
  • Re: Converting .bas files from VB 6.0 to VB.NET Project

    11-04-2009, 2:55 PM
    Answer
    • Contributor
      6,104 point Contributor
    • atconway
    • Member since 09-24-2007, 5:20 PM
    • Florida U.S.A
    • Posts 1,259

    .bas files in VB6 were 'Modules' and you can have modules if you need in .NET as well.  A module is basically a Public Class with methods marked as 'Shared'.  What this does is allow your code to call the methods in the module without having to make an instantiation of the class.

    I would reccomend creating a class as opposed to a module with the following declaration:

    Public Class MyClass
    
       Public Shared Function SayHello() As String
          Return "Hello!"
       End Function
    
    End Class

    You can use a module, but to get in the mindset of moving twoards more OOP and .NET methodologies, I would use a class.  I believe the module still exists for old VB6 developers as a 'comfort for conversion' and to help feel good in developing in .NET.  The code above is equivilent to accessing code in a module and could be accessed like in the sample code below:

    Dim MyString As String = String.Empty
    MyString = MyClass.SayHello()


    As mentioned before, there is no real great conversion path from VB6 to .NET, so some of the code regardless of the container used (class or module) is going to have to be manually updated to reflect the .NET equivilent.

    Hope this helps! Smile

    Thank you,   >[Blog]<

    "The best thing about a boolean is even if you are wrong, you are only off by a bit." :D
    -anonymous

Page 1 of 1 (3 items)