|
As the next version of Visual Basic looms on the horizon, due for release
H2, 2001, some fundaments VB coding approaches will have to
change to accommodate VB.NET. Here is a number of simple changes which are
required for VB.NET, and can be integrated into current versions of VB.
One thing is for sure, most of your current programs will not run in
VB.NET without some manual intervention, so employing these coding
procedures would make the transition easier.
Default Properties:
Object default properties such as Textbox1.Text, Checkbox1.Value
and Label1.Caption are currently optional and can be referenced as
Textbox1, Checkbox1 and Label1 respectively. These default properties are to be dropped in
VB.NET and must therefore be referenced explicitly.
Array Declarations:
Unspecified array element sizes are also to be dropped, so declarations such
as:
Dim arrData() As String
will no longer be accepted. Array declarations must
include the number of elements, as follows:
Dim arrData(5) As String
This will result in an array with 5 elements, with indexes 0 to 4. Direct
control Referencing:
Calling controls on a form externally, from a BAS module currently
works as all controls are Public, but VB.NET requires controls to be
declared as Public Shared for this to continue working. Ideally, controls
should be referenced through Public Property Get and Let procedures as
used in classes.
Sub & Function Declarations:
All parameters passed to procedures must either be ByVal or ByRef
explicitly. With VB.NET, ByVal is the default, but parameters must be
declared ByRef if the procedure is to change those parameters. Default
Optional Parameters:
Optional parameters in VB.NET will be handled
differently. At present, omitted optional parameters can be determined
with the IsMissing keyword. However, this keyword is to be dropped and all
optional parameters must have default values assigned in the event of
omissions. Further coding standards....
|