Visual Basic (versions 6 and below) code examples are everywhere. It’s a huge resource that many Visual FoxPro developers utilize, but converting a Visual Basic example to Visual FoxPro is, more often than not, a pain. It’s the same thing over and over again… change dims to locals, change msgbox to messagebox, add parenthesis around the procedure calls, etc., etc., ad nauseam.
As a programmer who develops in Visual Basic as well as Visual FoxPro, I was intrigued when, about a year ago on Tek-Tips, William GC Steinford offered the idea of a Visual Basic to Visual FoxPro converter. I decided it was a great idea and created my own. It is driven from a conversion table (of course), and handles most of the basic things that need to be changed when porting Visual Basic code to Visual FoxPro.
I’ve used it internally for awhile now, and it is a real time saver. Now, bear in mind that I’m not putting on a code clinic with this thing (like I said, I was just using it internally for some down and dirty conversions), but it’s functional and new vb to vfp syntax conversions can be added to the program just by adding records in the conversion.dbf. There are a couple of extra fields in that table as well that are reserved for future use (they will be used for such things as converting API Declare statements properly and such – basically anything that can’t be done in one pass through the conversion.dbf or needs special handling).
If you add to the conversion table or the program, I would really appreciate it if you would email me the changes. I would like to incorporate any useful changes with my own, and continue to offer them back to the Visual FoxPro community. Other than that, feel free to use it however or whenever you see fit.
A sample Visual Basic .BAS file has been included in the zip. When you run the vbtovfp.exe just click the ellipsis button […] and select the vbsample.bas file to open it in the conversion utility. Here’s a screen shot of vbtovfp and you can download vbtovfp here (source included).
Note: Originally written in VFP 7, but ported to VFP 9 – so, you will need VFP 9 to run this (or take the time to take out the VFP 9-only features and recompile it in whatever VFP you got). Also, there is selection/right-click functionality with the editboxes you’ll want to explore.