There really is no doubt about it.
The next version of Visual Basic will bring big changes. Web forms. A common runtime. Inheritance. Improved error handling. No DAO/RDO data binding support. New data types. No more WebClasses.
It’s all change – and more likely than not, your present day applications won’t easily port across, not even with the conversion tool Microsoft plan to ship.
So is there anything you can do to ready yourself for the move? There certainly is.
From the information we have so far, let’s review a ten-point coding checklist to ensure your applications will convert with the least fuss possible…
What can you do to ensure your applications port across to VB.Net with the least fuss possible? Here’s our printable ten-point coding checklist…
1. Stop Using Default Properties – Visual Basic 6 allows you to save on writing code by accessing the default properties of an object. For example, you can run Text1 = “Hello World” – as opposed to Text1.Text = “Hello World”. But in VB.Net, you must explicitly specify the property, function or method you want to use – don’t rely on defaults
2. Control Your Array Bounds – All arrays in VB.Net are zero-based, meaning you can’t define your own lower boundary. This means statements like Dim MyArray(1 to 10) As String will not be valid – arrays will always start at zero. And whilst Dim MyArray(5) As String in VB6 will create six elements, zero through to five – in VB.Net, it will create exactly five elements, starting at zero and finishing at four. This will also mean the end of Option Base. So when declaring your arrays, always make them zero-based
3. Stop Referencing Form Controls – It’s long been considered bad practice to directly reference a control on a form from within a BAS module. And in VB.Net, all controls on a form are deemed private unless explicitly altered. Therefore, improve both your code and VB.Net compatibility by implementing all communication between your module code and forms using property procedures
4. Make All Parameters ByRef or ByVal – When passing arguments in Visual Basic today, all intrinsic data types are ByRef by default, whilst everything else is ByVal. However in VB.Net, all parameters are ByVal. So don’t rely on the status quo – explicitly declare all parameters as either ByRef or ByVal to ensure fully-functional code now – and later
5. Use Default Values on Optional Parameters – VB.Net will see the removal of the IsMissing function – which doesn’t always work with the intrinsic data types anyway. So from now on, don’t check whether an optional parameter IsMissing – rather, specify a default value, like this: Function GetCustomers(Optional blnInState As Boolean = False)
6. Explicitly Declare All Variables – If you run Dim A, B, C As String in Visual Basic today, A and B will be Variants whereas C will be a String. In VB.Net however, this syntax will declare A, B and C as strings – bringing the program into line with other languages. Therefore, explicitly declare all variables to ensure you don’t run into problems
7. Wrap your API Calls – With VB.Net, various numeric data types will be rearranged – which could cause problems with API declarations. To keep things safe, try centralising all your API calls into a few modules, allowing you to fix any problems down the line with ease
8. Stop Using Currency and Variant Types – The Currency and Variant types will disappear with VB.Net. In place of Currency, you’ll probably want to use the Decimal data type or perhaps the improved 64-bit Long type – and although you can’t use decimals yet, you can declare a Variant and use the CDec function to make its subtype Decimal. And in place of modern day Variants, VB.Net will allow you to store the same data in the Object type something which is not possible at the moment – so wherever you can, it’s best to simply stop using Variants altogether
9. Get the SOAP Toolkit for Visual Studio 6 – SOAP, or Simple Object Access Protocol, is a method of exposing the interface of an object – then interacting with it – all via the Web. It’s essentially ‘DCOM on an even longer string’ and will play a big part in the Web Services section of the .Net strategy. And although implementing SOAP today isn’t as easy as it will be with VB.Net, obtaining the SOAP Toolkit will still give you a chance to get abreast of tomorrows technologies, today – www.microsoft.com/soap/
10. Get your Logic into Classes – Based on early reports, those applications with business logic tied in at the form layer won’t port easily to VB.Net, particularly given the big changes coming with Web Forms and WinForms. Therefore, get your business logic out of form modules – and into classes and components – if you’re looking for a smooth ride
(Top ten list based on information from VBPJ)