Some run-time code needs to be commented out to give the same effect as VB6
In Visual Basic 6.0 it was possible to write code that had no effect at run time, but that did not cause a compilation error. For example, the following code attempts to set the read-only BorderStyle property for a form at run time.
' Visual Basic 6.0 Form1.Borderstyle = 2 Debug.Print Form1.Borderstyle
This gave the result of 2, indicating that the BorderStyle had been changed, when in fact it had not — the BorderStyle was still the default (1).
When this code is upgraded to Visual Basic .NET it may cause unexpected results, since the BorderStyle constants are different. In other cases, code that did nothing in Visual Basic 6.0 may cause compilation errors in Visual Basic .NET.
What to do next
- If you want your application to behave as it did in Visual Basic 6.0, comment out (or delete) the line of code.
- If you intended for the line of code to be executed, modify the code. In the above example, if your intent was to actually make the border sizable, modify the code as follows:
' Visual Basic .NET Me.Borderstyle = Windows.Forms.FormBorderStyle.Sizable System.Diagnostics.Debug.WriteLine(Me.Borderstyle)