How do I convert my VB projects to Gambas?

There's a small script called vb2gb that splits VB .frm files into Gambas .form and .class files automatically. Not all controls or properties are supported, and binary .frx files are ignored, but it is quite useful for getting started. In the future, following the introduction of the Gambas perl-compatible regular expression component, this will be implemented in Gambas so that you'll be able to import VB .frm files directly.

The core of the script is a set of Perl regular expressions:

# Strings to translate (vb format => gb format)
my %trans = (
                '\r'              => '',
                'VERSION (.+)'    => '# Gambas Form File 1.0',
                'VB\.(.+)\s+(.+)' => '$2 $1',
                'Client(\w+)'     => '$1',
                'Begin\b'         => '{',
                'End\b'           => '}',
                'BorderStyle'     => 'Border',
                'Caption'         => 'Text',
                'Command'         => 'Button',
                'CommandButton'   => 'Button',
                'ButtonButton'    => 'Button',
                'Label'           => 'TextLabel',
                '\"(.+)\"'        => '("$1")',
                'VScrollBar'      => 'Scrollbar',
                'HScrollBar'      => 'Scrollbar'
);

# Twips properties that must be converted to pixels
my @twips = qw (Top Left Width Height);

# Strings we don't know how to translate
my @nontrans = qw (
                        LinkTopic MaxButton MinButton ScaleHeight ScaleMode
                        ScaleWidth ShowInTaskbar TabIndex Picture
                        StartUpPosition Alignment BackStyle
);

The script is useful to translate the project interface, but you'll still have to translate some code manually.

See also: Differences from VB


Nelson, how about attaching the latest version of the script? As long as you make people aware it's not finished they shouldn't mind. Also, I haven't stopped tweaking my own script (which is more traditional and less Perl-escent, which will be helpful when it's time to translate our code into Gambas) and while it hasn't come as far as yours, I think I can probably patch yours to support e.g. tab controls. -- RobKudla - 28 Aug 2003

Here it is! -- NelsonFerraz - 30 Aug 2003

Attachment: Action: Size: Date: Who: Comment:
vb2gb.tgz action 1410 29 Aug 2003 - 16:35 NelsonFerraz vb2gb 0.1