Loading in 2 Seconds...
Loading in 2 Seconds...
DEV230 Upgrading VB 6 Applications to Visual Basic .NET. Keith Pleas Architect, Guided Design [email protected] Overview. Language changes – code, object, data Classic Visual Basic “Ruby” forms to Windows Forms Upgrade Tools & Utilities The Upgrade Process - Examples.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Keith PleasArchitect, Guided [email protected]
' Some typical processing logic
Catch excError as Exception When Expression
' This code runs when an error occurs
' in the code above
LogError ("Unable to update the recordset")
' This code always runs, either after the
' Try code if there was no error, or after
' the Catch code if there was
Dim x, y As Integer ' both are integers
Dim intHours As Integer = 20
Dim intMinutes as Integer = intHours * 60
Dim strNames() as String = ("Moe", "Larry", "Curly")
RecID As Integer
Location As String*20
Status As Boolean
Closest match in VB.NET is:
Public RecID As Integer
Public Location As String 'Variable length string!
Public Status As Boolean
No fixed-length strings (caveat)
Dim myData as Integer = 10
Public Property Data( ) As Integer
Set(ByVal Value As Integer)
myData = Value
Public Sub DoStuff(x As Integer)
Public Function GetStuff( ) As Integer
Public Event UpdateTime(dblJump As Double)
Public Sub TimerTask(Duration As Double)
RaiseEvent UpdateTime(Timer - dblJump)
Public WithEvents mText As TimerState
Private Sub Button1_Click(ByVal sender as Object, _ ByVal e as EventArgs) Handles Button1.Click
Dynamic "AddHandler", "RemoveHandler"
Private Sub myClick(ByVal sender As Object, _ ByVal e As EventArgs)
AddHandler Button1.Click, New EventHandler(AddressOf myClick)
RemoveHandler Button1.Click, AddressOf myClick
d = CType([Delegate].Combine(d, y.cb), OutputDelegate)
Public Sub New( )
Can be Overloaded (no keyword)
Public Sub New(ByVal i As Integer)
Public Sub New(ByVal i As Integer, ByVal s As String)
' Separate (as in VB 6.0)
Dim my1 As myClass
my1 = New myClass( ) 'Default constructor
' At the same time
Dim my2 As myClass = New myClass( )
Dim my3 As New myClass( )
' Other constructors
Dim my4 As New myClass(10)
Dim my5 As myClass = New myClass(10)
Me.Move (Screen.Width - Me.Width), _ (Screen.Height - Me.Height) / 2
Me.StartPosition = FormStartPosition.CenterScreen
Me.MousePointer = vbHourglass
Me.Cursor.Current = Cursors.WaitCursor
TextBox1.Anchor = _ AnchorStyles.Top _ Or AnchorStyles.Left) _
Panel1.Dock = DockStyle.Bottom
Dim frmDialogForm As DialogForm
Set frmDialogForm = New DialogForm
Dim frmDialogForm As New DialogForm
Extending the “Code Advisor”
Dim prpObj As Property
'FIXIT: Declare 'vTmp' with an early-bound data type FixIT90210ae-R1672-R1B8ZE
Dim vTmp As Variant
'FIXIT: Declare 'vNew' with an early-bound data type FixIT90210ae-R1672-R1B8ZE
Dim vNew As Variant
Dim frmProp As New frmProperty
'UPGRADE_WARNING: Couldn't resolve default property of object Me.Left. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
'UPGRADE_WARNING: Couldn't resolve default property of object Me.Width. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Me.Left = (VB6.PixelsToTwipsX(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width) - Me.Width) / 2
'UPGRADE_WARNING: Couldn't resolve default property of object Me.Top. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
'UPGRADE_WARNING: Couldn't resolve default property of object Me.Height. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Me.Top = (VB6.PixelsToTwipsY(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height) - Me.Height) / 2
Caution: Functions in the Visual Basic 6.0 Compatibility library are provided only for use by the upgrading tools. Although it is possible to use this library when writing new code, there is no guarantee that it will be supported in future versions of Visual Basic.
MTS or COM+ objects were not upgraded
The project that you are attempting to upgrade has a reference to the COM+ Services Type Library (Comsvcs.dll) that cannot be upgraded. In Visual Basic 6.0, this library was used to access Microsoft Transaction Services (MTS). In Visual Basic .NET, MTS is replaced by transaction processing functionality in the .NET Framework.
Because of differences in the transaction processing models, existing code will need to be deleted and replaced by code that uses .NET transaction processing.
Dim / ReDim Preserve
MTS objects not upgraded
Converse online with Microsoft Newsgroups, including Worldwide
Meet and learn with your peers
The tools you need to put technology to work!
Upgrading Microsoft® Visual Basic® 6.0 to Microsoft Visual Basic .NET: 0-7356-1587-X
This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.