basta! 2010 - vb6 migration: tips, traps, and techniques
TRANSCRIPT
Me.About the Programming Microsoft Visual Basic series
MSDN Regional director, Italy
VB Migration Partner
www.vbmigration.com
Code Architects Visual Studio Industry Partner (VSIP)
the only Microsoft ISVNXT partner specialized in conversion and modernization of VB6 apps
customers in Europe, United States & Canada, Australia and Asia
dozens of millions of lines of code migrated
official Microsoft Case study published on Microsoft.com, ERP system of about 1M lines of code
migration FAQswhy migrating to .NETmigrating vs. porting vs. extendingusing conversion toolsthe C# alternative
“language impedance” data types type-char suffix Array lower bounds Optional params As New variables Byval argument passing Defxxx array rank missing As As Any parameters block variables date as double array assignments callbacks in Declare As New arrays UDT initialization Variants default parameterless members Gosub On Goto/GoSub Byref ParamArray Fixed-length strings UDT assignments byte-oriented string functions enum/number conversions IsMissing Empty value Null propagation VarPtr, ObjPtr, StrPtr class termination IDisposable objects default members in late-binding OLE control Line and Shape controls control arrays graphic methods ScaleMode property DrawMode property DAO and RDO data-binding ADO data-binding ADO data-bound classes DataEnvironment VBControlExtender object PropertyPages UserDocuments “classic” drag-and-drop OLE drag-and-drop Extender and Ambient properties DDE WebClasses DHTML Pages Sub Main in DLLs SingleUse classes Global classes COM+ components class persistence Print and Printers App, Screen, Forms objects ActiveX EXEs popup menus
conceptsparser and code analyzerpre/post processingmigration pragmascode generation enginesupport librarycode analysis & refactoring
concepts (in 75 minutes)parser and code analyzerpre/post processingmigration pragmascode generation enginesupport librarycode analysis & refactoring
before migrating... use array with Lbound = 0 avoid Variants, if possible
late binding Null propagation
create wrapper methodsfile I/Ographicsdata accessWindows API calls (As Any, VarPtr, StrPtr)
remove unused and unreachable code
support library many VB6 methods are missing or don’t
preserve functional equivalence CDate, IsDate, IsObject Str, StrConv AscB, ChrB, LeftB, MidB, RightB, ... MsgBox, InputBox FileDateTime, Dir VarType, TypeName IsMissing, IsEmpty, IsNull DoEvents SavePicture, LoadPicture ...
post-processing
• process the output from UW– leverage existing upgrade warnings
• can‘t replace a real parser, but it’s enough for many common issues
post-processing
examples library methodsDoEventsControls.AddUDT initializationfixed-length strings inside UDTdefault methods in late-binding mode
migration pragmas
similar to compiler directives
• special remarks with '## prefix '## ArrayBounds ForceZero
project, file, method, variable scope '## project:ConvertGosubs True '## myvar.InferType
convert-test-fix methodology
migration pragmas examples
ExcludeStatement InsertStatement ReplaceStatement AutoNew AutoDispose ReplaceCurrentFile IncludeFile
refactoring with PostProcess Not x Is y x IsNot y Dim x As Short : x = 1 Dim x As Short = 1 Dim x As Short: For x = 1 For x As Short =
1 While…End While Do…Loop If x = True Then If x Then If x = False Then If Not x Then If bool1 And bool2 If bool1 AndAlso bool2 … If bool1 Or bool2 If bool1 OrElse bool2 …
more details here: www.vbmigration.com/blog
VB Migration Partner VB6 project groups all VB6 keywords (except VarPtr, ObjPtr, StrPtr)
advanced code analysis and refactoring 70+ VB6 controls, drag-and-drop, popup
menus graphic methods, user-defined ScaleMode null propagation in expressions (the VB6Variant
type) ADO, DAO, RDO data-binding try-catch, gosubs, nested Ifs, type inference ADODB -> ADO.NET migration (ADOLibrary)
pragmas & convert-test-fix methodology
VB6 migration: tips, traps, and tricks knowledge base, videos, code samples,
articles, links, and resources atwww.vbmigration.com
slides available atwww.slideshare.net/VBMigrationPartner
blogwww.vbmigration.com/blog
LinkedIn Group on VB6 Migrationwww.linkedin.com/groups?gid=3074090
Facebook Fan Page on VB6 Migrationfacebook.com/FrancescoBalenaOnVB6Migration
Get free advice Each VB6 application is different and creates
unique challenges in the migration to .NET.
To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file.
You will receive a detailed report on your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.www.vbmigration.com/getfreeadvice.aspx