Loading Windows forms has different behavior


Summary Using the Visual Basic Upgrade Wizard in Visual Studio to auto-translate Visual Basic 6 (VB6) code to Visual Basic .NET (VB .NET) is not 100 percent automated. This topic shows ArcGIS developers how to manually correct code where loading Windows forms will not work after the auto-translation.

About loading Windows forms has different behavior

The following are example VB .NET errors:
  • Error 1 Name 'Load' is not declared.
  • Error 2 'frmAlgorithmicColorRamp' is a type and cannot be used as an expression.
  • Error 3 Reference to a non-shared member requires an object reference.
  • Error 4 Reference to a non-shared member requires an object reference.
The following is the cause of the VB .NET error:
  • In VB6, the Load statement can be used to load a form without displaying it. You can also load a form without displaying it by referencing any of its properties. The Load statement is no longer supported in VB .NET. When an instance of a form is created by using the New keyword, it is not loaded until the Show method is called.
The following is the original VB6 code:
Load frmAlgorithmicColorRamp
frmAlgorithmicColorRamp.m_lngClasses = pCBRend.BreakCount
frmAlgorithmicColorRamp.Show vbModal
The following shows the initial auto-translated code and the correct VB .NET translation code:
[VB.NET]
'Initial auto-translated VB .NET conversion.
Load(frmAlgorithmicColorRamp)
frmAlgorithmicColorRamp.m_lngClasses = pCBRend.BreakCount
frmAlgorithmicColorRamp.ShowDialog()
[VB.NET]
'Correct VB .NET translation.
Dim frmAlgorithmicColorRamp As New frmAlgorithmicColorRamp
frmAlgorithmicColorRamp.m_lngClasses = pCBRend.BreakCount
frmAlgorithmicColorRamp.ShowDialog()


See Also:

Migrating from VB6 to VB.NET
General steps for migrating from VB6 to VB.NET




Development licensing Deployment licensing
ArcView ArcView
ArcEditor ArcEditor
ArcInfo ArcInfo
Engine Developer Kit Engine Runtime