Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Francesco Balena – Code Architects, Italy VB6 Migration: Tips, Traps, and Techniques
Me.About <ul><li>the  Programming Microsoft Visual Basic  series </li></ul><ul><li>MSDN Regional director, Italy </li></ul...
Code Architects <ul><li>Visual Studio Industry Partner ( VSIP ) </li></ul><ul><li>the only Microsoft  ISVNXT  partner spec...
migration FAQs <ul><li>why migrating to .NET </li></ul><ul><li>migrating vs. porting vs. extending </li></ul><ul><li>using...
“ language impedance” <ul><li>   data types    type-char suffix    Array lower bounds    Optional params    As New va...
“ language impedance” (UW)
“ language impedance” (VBMP)
hidden traps <ul><li>strings </li></ul><ul><li>parameter passing </li></ul><ul><li>math operations </li></ul><ul><li>colle...
concepts <ul><li>parser and code analyzer </li></ul><ul><li>pre/post processing </li></ul><ul><li>migration pragmas </li><...
concepts (in 75 minutes) <ul><li>parser and code analyzer </li></ul><ul><li>pre / post processing </li></ul><ul><li>migrat...
before migrating... <ul><li>use array with Lbound = 0 </li></ul><ul><li>avoid Variants, if possible </li></ul><ul><ul><li>...
support library <ul><li>many VB6 methods are missing or don’t preserve functional equivalence </li></ul><ul><ul><li>CDate,...
post-processing <ul><li>process the output from UW </li></ul><ul><ul><li>leverage existing upgrade warnings </li></ul></ul...
post-processing <ul><li>examples </li></ul><ul><ul><li>library methods </li></ul></ul><ul><ul><li>DoEvents </li></ul></ul>...
migration pragmas <ul><li>similar to compiler directives </li></ul><ul><li>special remarks with  '##   prefix </li></ul><u...
migration pragmas <ul><li>examples </li></ul><ul><ul><li>ExcludeStatement </li></ul></ul><ul><ul><li>InsertStatement </li>...
refactoring with PostProcess <ul><li>Not x Is y    x IsNot y </li></ul><ul><li>Dim x As Short : x = 1    Dim x As Short ...
VB Migration Partner <ul><li>VB6 project groups </li></ul><ul><li>all VB6 keywords  (except VarPtr, ObjPtr, StrPtr) </li><...
VB6 migration:  tips, traps, and tricks <ul><ul><li>knowledge base, videos, code samples, articles, links, and resources  ...
Get free advice <ul><li>Each VB6 application is different and creates  unique  challenges in the migration to .NET. </li><...
Upcoming SlideShare
Loading in …5
×

Basta! 2010 - VB6 Migration: Tips, Traps, and Techniques

2,167 views

Published on

Francesco Balena's speech at Basta! 2010 conference in Germany on September 23rd:

VB6 Migration: Tips, Traps, and Techniques

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Basta! 2010 - VB6 Migration: Tips, Traps, and Techniques

  1. 1. Francesco Balena – Code Architects, Italy VB6 Migration: Tips, Traps, and Techniques
  2. 2. Me.About <ul><li>the Programming Microsoft Visual Basic series </li></ul><ul><li>MSDN Regional director, Italy </li></ul><ul><li>VB Migration Partner </li></ul><ul><li>www.vbmigration.com </li></ul>
  3. 3. Code Architects <ul><li>Visual Studio Industry Partner ( VSIP ) </li></ul><ul><li>the only Microsoft ISVNXT partner specialized in conversion and modernization of VB6 apps </li></ul><ul><li>customers in Europe, United States & Canada, Australia and Asia </li></ul><ul><li>dozens of millions of lines of code migrated </li></ul><ul><li>official Microsoft Case study published on Microsoft.com, ERP system of about 1M lines of code </li></ul>
  4. 4. migration FAQs <ul><li>why migrating to .NET </li></ul><ul><li>migrating vs. porting vs. extending </li></ul><ul><li>using conversion tools </li></ul><ul><li>the C# alternative </li></ul>
  5. 5. “ language impedance” <ul><li> 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  </li></ul>
  6. 6. “ language impedance” (UW)
  7. 7. “ language impedance” (VBMP)
  8. 8. hidden traps <ul><li>strings </li></ul><ul><li>parameter passing </li></ul><ul><li>math operations </li></ul><ul><li>collections </li></ul><ul><li>fields </li></ul><ul><li>... and a lot more </li></ul>
  9. 9. concepts <ul><li>parser and code analyzer </li></ul><ul><li>pre/post processing </li></ul><ul><li>migration pragmas </li></ul><ul><li>code generation engine </li></ul><ul><li>support library </li></ul><ul><li>code analysis & refactoring </li></ul>
  10. 10. concepts (in 75 minutes) <ul><li>parser and code analyzer </li></ul><ul><li>pre / post processing </li></ul><ul><li>migration pragmas </li></ul><ul><li>code generation engine </li></ul><ul><li>support library </li></ul><ul><li>code analysis & refactoring </li></ul>
  11. 11. before migrating... <ul><li>use array with Lbound = 0 </li></ul><ul><li>avoid Variants, if possible </li></ul><ul><ul><li>late binding </li></ul></ul><ul><ul><li>Null propagation </li></ul></ul><ul><li>create wrapper methods </li></ul><ul><ul><li>file I/O </li></ul></ul><ul><ul><li>graphics </li></ul></ul><ul><ul><li>data access </li></ul></ul><ul><ul><li>Windows API calls (As Any, VarPtr, StrPtr) </li></ul></ul><ul><li>remove unused and unreachable code </li></ul>
  12. 12. support library <ul><li>many VB6 methods are missing or don’t preserve functional equivalence </li></ul><ul><ul><li>CDate, IsDate, IsObject </li></ul></ul><ul><ul><li>Str, StrConv </li></ul></ul><ul><ul><li>AscB, ChrB, LeftB, MidB, RightB, ... </li></ul></ul><ul><ul><li>MsgBox, InputBox </li></ul></ul><ul><ul><li>FileDateTime, Dir </li></ul></ul><ul><ul><li>VarType, TypeName </li></ul></ul><ul><ul><li>IsMissing, IsEmpty, IsNull </li></ul></ul><ul><ul><li>DoEvents </li></ul></ul><ul><ul><li>SavePicture, LoadPicture </li></ul></ul><ul><ul><li>... </li></ul></ul>
  13. 13. post-processing <ul><li>process the output from UW </li></ul><ul><ul><li>leverage existing upgrade warnings </li></ul></ul><ul><li>can‘t replace a real parser, but it’s enough for many common issues </li></ul>
  14. 14. post-processing <ul><li>examples </li></ul><ul><ul><li>library methods </li></ul></ul><ul><ul><li>DoEvents </li></ul></ul><ul><ul><li>Controls.Add </li></ul></ul><ul><ul><li>UDT initialization </li></ul></ul><ul><ul><li>fixed-length strings inside UDT </li></ul></ul><ul><ul><li>default methods in late-binding mode </li></ul></ul>
  15. 15. migration pragmas <ul><li>similar to compiler directives </li></ul><ul><li>special remarks with '## prefix </li></ul><ul><ul><li>'## ArrayBounds ForceZero </li></ul></ul><ul><li>project, file, method, variable scope </li></ul><ul><ul><li>'## project:ConvertGosubs True </li></ul></ul><ul><ul><li>'## myvar.InferType </li></ul></ul><ul><li>convert-test-fix methodology </li></ul>
  16. 16. migration pragmas <ul><li>examples </li></ul><ul><ul><li>ExcludeStatement </li></ul></ul><ul><ul><li>InsertStatement </li></ul></ul><ul><ul><li>ReplaceStatement </li></ul></ul><ul><ul><li>AutoNew </li></ul></ul><ul><ul><li>AutoDispose </li></ul></ul><ul><ul><li>ReplaceCurrentFile </li></ul></ul><ul><ul><li>IncludeFile </li></ul></ul>
  17. 17. refactoring with PostProcess <ul><li>Not x Is y  x IsNot y </li></ul><ul><li>Dim x As Short : x = 1  Dim x As Short = 1 </li></ul><ul><li>Dim x As Short: For x = 1  For x As Short = 1 </li></ul><ul><li>While…End While  Do…Loop </li></ul><ul><li>If x = True Then  If x Then </li></ul><ul><li>If x = False Then  If Not x Then </li></ul><ul><li>If bool1 And bool2  If bool1 AndAlso bool2 … </li></ul><ul><li>If bool1 Or bool2  If bool1 OrElse bool2 … </li></ul><ul><li>more details here: www.vbmigration.com/blog </li></ul>
  18. 18. VB Migration Partner <ul><li>VB6 project groups </li></ul><ul><li>all VB6 keywords (except VarPtr, ObjPtr, StrPtr) </li></ul><ul><li>advanced code analysis and refactoring </li></ul><ul><li>70+ VB6 controls, drag-and-drop, popup menus </li></ul><ul><li>graphic methods, user-defined ScaleMode </li></ul><ul><li>null propagation in expressions (the VB6Variant type) </li></ul><ul><li>ADO, DAO, RDO data-binding </li></ul><ul><li>try-catch, gosubs, nested Ifs, type inference </li></ul><ul><li>ADODB -> ADO.NET migration (ADOLibrary) </li></ul><ul><li>pragmas & convert-test-fix methodology </li></ul>
  19. 19. VB6 migration: tips, traps, and tricks <ul><ul><li>knowledge base, videos, code samples, articles, links, and resources at www.vbmigration.com </li></ul></ul><ul><li>slides available at www.slideshare.net/VBMigrationPartner </li></ul><ul><li>blog www.vbmigration.com/blog </li></ul><ul><li>LinkedIn Group on VB6 Migration www.linkedin.com/groups?gid=3074090 </li></ul><ul><li>Facebook Fan Page on VB6 Migration facebook.com/FrancescoBalenaOnVB6Migration </li></ul>
  20. 20. Get free advice <ul><li>Each VB6 application is different and creates unique challenges in the migration to .NET. </li></ul><ul><li>To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. </li></ul><ul><li>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 </li></ul>

×