In converting VB6 Applications to VB.NET, I many times do not use the migration tool that comes with VB.NET. There are several reasons for this. First, if ADO is involved, the tool does convert to ADO.Net. That would take a tool that is much more powerful than the migration tool and I am not sure that any such tool could catch everything. Secondly, the migration tool generates hundreds of diagnostics and warnings, many of which could be ignored, except that you have to go to the trouble of deleting them after you have looked at them to see whether they can be ignored. This is certainly not to imply that you can ignore all of the warnings or errors.
I often find it easier to do the conversion manuallly, becuase the errors will be obvious once you drop a method from VB6 into VB.Net, especially if you do not have an import and Reference to the classic ADO object library. There are several gotchas that will grab at run-time, and not necessarily at compile time.
The first and one of the most dangerous is the old ByRef/ByVal problem. Many times developers in VB6 did not declare whether a value is expected to be passed to a method ByVal or ByRef. In VB6, the compiler would not automatically fill this in for the developer as VB.Net does. For example, consider the following code snippet in VB6. The developer is passing a reference to a string that he expects to have a value returned in. The developer used a Sub rather than a Function because he/she needed to have the method return more than one value.
| Dim s As String Dim s2 As String MethodOne(s, s2) ........ Private Sub MethodOne(p1 As String, p2 As String) p1 = "A" p2 = "B" End Sub |
| fileName = Format(Now, "MMddyy") & Format(CStr(seqNum), "000") & ".ERR" |
| fileName = Format(Now, "MMddyy") & Format(CStr(seqNum), "000") & ".ERR" |
| Ask a Question, or give your feedback on my articles or products by going to the KnowDotNet Forum or by clicking on My Blog. | ![]() |