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



For an alternative approach (that drops unknown attributes and doesn't try to convert the code, but which should always produce a legal Gambas form) try my script, frm2form. -- RobKudla - 01 Sep 2004


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