Are you having trouble converting VB6 project to VB.net Visual Studio 2010. Well just to be frank you should have long back converted this VB6 project of yours to VB.net. VB6 is ancient and just because your code works doesn’t mean that you won’t migrate it to a newer platform. In my opinion let your customers use the VB6 project of yours while you in the background should have converted a copy of it to VB.net. Now you might say it’s too much work… well how about it now. ;)

Just to be clear Visual Studio 2010 does NOT inherently support converting VB6 project to VB.net 2010. When I force a conversion (via project open dialog) I get the following error dialog…

VB6 to VB.net 2010 - Conversion Error

VB6 to VB.net 2010 - Conversion Error

Recently Mr. X asked me this question so I sent him an email with the steps on converting a VB6 project to VB.net Visual Studio 2010. So here are the steps (straight from the email I sent to the customer…)

  1. Make sure VB 6.0 with SP 6.0 installed on the machine.
  2. Make sure that all the referenced components (ActiveX dll, OCX) for the VB 6.0 application is available on the machine.
  3. Open the VB 6.0 project in VB 6.0 IDE and make sure that it opens fine. Build the project and make sure that the application executes without any errors.
  4. Run the Upgrade assessment tool on the visual basic 6 project:
    (Old one) http://www.microsoft.com/downloads/details.aspx?FamilyId=10C491A2-FC67-4509-BC10-60C5C039A272&displaylang=en
    (New one) http://www.artinsoft.com/visual-basic-upgrade-assessment-tool.aspx
  5. Keep a local copy of the VB 6.0 project
  6. There is no direct wizard conversion in Visual Studio 2010. You have to first use the conversion wizard available in Visual Studio 2005/2008 to convert to VB.net and then convert the same to Visual Studio 2010. As you don’t have Visual Studio 2008, you can download free version from following link.
    http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express
  7. Once you are done with the conversion you can uninstall Visual Studio 2008 express edition.
  8. Also you can download a free guide which contains information about Upgrading Visual Basic 6.0 Applications to Visual Basic .NET and Visual Basic 2005 (Its bit old but it will give useful insights as and when you are migrating source code to .net).
    http://www.microsoft.com/downloads/details.aspx?FamilyId=7C3FE0A9-CBED-485F-BFD5-847FB68F785D&displaylang=en

 A general note:

 As per the upgrade guide, the effect of the changes and subtle differences in Visual Basic .NET is that, unlike previous versions of Visual Basic, most real-world projects cannot be upgraded 100 percent automatically. To understand why, consider that for a 100 percent upgrade there has to be a one-to-one correlation between every element of Visual Basic 6 and a corresponding element in Visual Basic .NET. Unfortunately, this correlation does not exist. The upgrade process is closer to 95 percent, meaning that the Visual Basic .NET Upgrade Wizard upgrades 95 percent of your application, and you modify 5 percent of the application to get it working. What does 5 percent mean? If it took you 100 days to write the original Visual Basic 6 application, you might expect to take 5 days to upgrade it. This number is not set in stone-some applications are easier to upgrade than others, and the experience of the person doing the upgrade is an important factor. To prepare yourself, make sure you familiarize yourself with Part IV of the upgrade guide. It discusses how to design your Visual Basic 6 applications to make the upgrade process much smoother.

Microsoft Visual Basic 6.0 Migration Resource Center
http://msdn.microsoft.com/hi-in/vbrun/ms788233(en-us).aspx

Share
 

Read the following article in MSDN:

http://msdn.microsoft.com/en-us/library/5hs4b7a6.aspx

The easiest way to disable JIT debugger is via the Tools->Options dialog in Visual Studio. For other options read the article.

Enable/Disable Just in Time Debugger in Visual Studio Options dialog

Enable/Disable Just in Time Debugger in Visual Studio Options dialog

Share
 





Share
 

Recently I worked on one C# project. Got to say it’s hell lot easier to code :-) . Found something cool while working on template based List class.

Guess that you got a list of employees stored in List, so how will you locate a particular employee by his name or based on certain employee attributes: like list all employees having salary greater than a particular employee. So our employee class will look like…

class Employee
{
  public bool IsSalaryGt(Object Emp) { return ((Emp as Employee).m_Sal > m_Sal); }
  private int m_Sal; // Init to some val
}

class Main
{
  private List<Employee> m_Emps;

  //So to locate all employees having salary greater than me we will  write
  void ListAllEmps_EarningMoreThanMe(Employee Me)
  {
    List< Employee > Emps = m_Emps.FindAll(Me.IsSalaryGt);
  }
}
Share
Jun 012008
 

It’s quite easy to work with WMI in .net. Follow these steps to get details of Win32_VideoController.

Namespace to use is System.Management.

1. Create a management class object.

Dim MngClass As New ManagementClass("Win32_VideoController")

2. Create a management object class collection instance and fill out this collection likewise…

Dim MngObjCollection As ManagementObjectCollection = MngClass.GetInstances

' Now we need to iterate through this collection object likewise...
For Each MngObj As ManagementObject In MngObjCollection
    Dim PropCollection As PropertyDataCollection = MngObj.Properties
    For Each PropData As PropertyData In PropCollection
       ' Read in properties of video controller.
    Next PropData
Next MngObj

Well we are done, quite easy isn’t it? Do this in C++ and you will be breaking your head and fingers.

Change the name of the above WMI class to something else and it will work in the same way except for properties of the WMI class object since each class has different properties.

Look up MSDN for more details on the properties of WMI classes. As a homework try fetching properties of “Win32_Processor”.

Download a sample application which extensively uses WMI to fetch details of remote machines. There are two exe’s and one dll. Put them in the same directory and run both exe’s. The one with a blue icon is the client application and the one with a red icon is the server application. You can run these applications locally or as remote ones putting the client application in a remote machine. See the power of WMI in full flow.

Share
 

netstat is a cool tool to view all active tcpip/udp connections in our computer along with the names of applications who have opened these ports/connections.

So as a demo open up command prompt and type

netstat /a
netstat /b -> displays exes which are using a particular port/connection
netstat /? -> displays helps for this command

I would have a given a screen shot here but for security reasons.

So in MSDN there is an equivalent tool written in .net (cool). You can download it from here, works well!

Share
 

One of the classes in .Net that I like is the StringBuilder class. So what is it? It’s like the StringBuffer class in java.

It’s a mutable string class which does faster operation while concatenation and other string related functions because internally it doesn’t recreate String objects but maintains a big enough buffer to prevent frequent re-allocations to manage concatenations.

I remember using String for concatenation in one of my .Net projects while I started programming in .Net. I knew there should be something like StringBuffer in Java. So while I was performance testing my application I found my application to be real slow. Main reason for this performance hit was String. I was “misusing” this class and doing concatenations with it. I replaced such calls with equivalent StringBuilder calls. Improvement in performance was just mind blowing phew about 20 times faster.

This class is in the System.Text namespace.

An e.g. code snippet in VB.net

Dim CIStr As New System.Text.StringBuilder

' Heavy operations
CIStr.Append( SomeString1 )
CIStr.Append( SomeString2 )
CIStr.Append( SomeString3 )
CIStr.Append( SomeString4 )
CIStr.Append( SomeString5 )

'Use ToString to get internal string
CIStr.ToString()
Share
© 2012 bits and bytes Suffusion theme by Sayontan Sinha