-2

I am trying to convert a large (200K lines) VB6 project into C#. I only want to convert the form design because I want to rewrite all the actual code in C#.

I want to use the free Artinsoft converter but this only allows projects of 10K lines. I am thinking I could break the VB6 project into 20 separate projects and then generate the C#.NET forms by using Artinsoft, then bringing the converted forms back into one C# project.

Is this feasible?

EDIT: Will this work? What are the potential problems?

CJ7
  • 22,579
  • 65
  • 193
  • 321
  • Define "feasible". What would make it infeasible to you? This question is subjective. –  Nov 20 '11 at 08:27
  • 2
    So, you are basically asking us how to/if you can defeat the licensing scheme of this program? How would you feel about someone asking us how to do the same thing to one of your programs? – Andrew Barber Nov 20 '11 at 08:32
  • @AndrewBarber: It's not like I'm using the program to full capacity. I'm just trying to convert the form design. This would hardly amount to 10000 lines if I stripped out all of the code from the .frm files. Perhaps I should just do that... – CJ7 Nov 20 '11 at 08:37
  • That doesn't seem like what your question said. At any rate, I think you are heading for a really hair-pulling experience. You are going to make an already somewhat fragile process about 10x more complex. Good luck.. – Andrew Barber Nov 20 '11 at 08:43
  • 2
    It's my opinion that in the end, the troubles you will run into will be as much or more than the trouble you would have spent just recreating the forms. – Brandon Moore Nov 21 '11 at 02:29
  • @AndrewBarber: In fairness, the program costs [in excess of eight thousand dollars](http://www.artinsoft.com/visual-basic-upgrade-companion-pricing.aspx) to do what the OP needs. – Boann Nov 21 '11 at 09:25
  • 1
    @Boann Well, it's a trade-off; lines of code versus time spent. Time is money, and I think it's surprising how often people completely ignore that fact when considering the cost of a programming tool. But given what it seems the OP is wanting to try to do, I think it's probably best to do the whole conversion manually. – Andrew Barber Nov 21 '11 at 09:35
  • @BrandonMoore Absolutely agreed. I think a straight conversion is hard enough as it is; trying to split things up, and only convert part of it is just asking for more complexity. – Andrew Barber Nov 21 '11 at 09:36

2 Answers2

1

I will try it in following order

1) Write automated test cases at least for major business operations

this will save you a lot of bother verifying the results later on.

2) Refactor your VB (try to move out your business logic in separate Classes/DLLs).

3) you can verify your re-factoring using automated test cases written in step 1.

4) Now you have small chunks this will also help you create chunks then you can use Artinsoft.

5) Your new C# application will be nicely layered.

6) Run tests created in step 1 on your new application and on your old application and compare results and keep improving unless they match :)

Surjit Samra
  • 4,614
  • 1
  • 26
  • 36
1

I would advise against using a converter for the UI. It may seem trivial, but there are features that simply do not natively exist in .NET (control arrays without a wrapper for a big one). And the control wrappers it creates are not fun to use nor maintain.

VB6 does not port well; the UI nor the code. If you were to continue down this path, there are things that can help.

  1. Remove all unused forms and code
  2. Ensure there are no control arrays and if there are, correct related code
  3. Get all logic wrapped in classes
  4. Ensure you are not calling/loading/referencing forms directly and that you are using an instantiated object
  5. Ensure good encapsulation practices are in use and good object oriented design patterns

I would seriously reconsider conversion. Converted code/UI sounds great, but in my bad experiences with VB6 conversion, there are so many problems because of how bad VB6 allowed developers to be and features that simply don't exist anymore.

Do yourself a huge favor... Start a new project, create a custom control library that inherits from the standard controls you use, and use those everywhere. Don't like the way Cliptext works on a masked textbox in C# versus VB6? Extend it or override it. Want all your listviews to be sortable? Easy, single-point implementation. Find out in a year that the business wants spell checking on 90% of textboxes? Easy.

UnhandledExcepSean
  • 12,504
  • 2
  • 35
  • 51