Porting Visual Basic apps to Linux

Opening Doors


Realbasic provides an easy solution for converting Visual Basic programs to Linux.

By Frank Wieduwilt

www.sxc.hu

Visual Basic owes its popularity in the world of Windows to its reputation as an easy-to-learn and easily readable programming language. But users moving to Linux typically have to re-write their Visual Basic programs in a different language. Free Basic variants such as Gambas [1], HBasic [2], or WXBasic [3] are just too far removed from VB to support no-worries porting. KBasic [4] promises complete syntactical compatibility to Visual Basic, but it is still at a fairly unstable beta stage despite several years of development. Real Software recently launched Realbasic [5], a commercial tool designed to pick up Visual Basic projects and give users the ability to run them on Linux and Mac OS X.

The Realbasic licensing model is slightly unusual. In addition to the right to use the program, customers additionally purchase the right to free bug fixes and enhancements for a fixed period of time. After this time, the customer retains the license but does not get the bugfixes. Real Software promises to release a new version every 90 days, so licensed users can look forward to new features at regular intervals.

The Standard Edition for Linux is free; the Professional Version costs 330 Euros (US$ 399.95) with six months worth of updates. Other license arrangements are also available. Table 1 shows the differences between the two versions.

The Professional version of Realbasic for Linux can create programs for any Windows version from 95 through to XP. The programs do not require any additional DLL files, and Realbasic programs in Linux comprise a single executable. The Standard version can also produce binaries for testing on Windows and Mac OS, although the program runtime is restricted to five minutes.

Installation

The binary packages were easy to install. Red Hat Desktop Linux and Novell Desktop Linux users can download the Realbasic RPMs; there is also a TGZ archive. Both variants work perfectly on any recent distribution. The PDF-based documentation is also available from the Realsoftware homepage.

When first launched, the program prompts you to enter your name and email address before it downloads the license key.

GUI

The Realbasic GUI can hold sway with most other modern developer environments (see Figure 1). Programmers moving from Visual Basic will find their way around just as quickly as those familiar with other IDEs. The editor supports syntax highlighting and completion of keywords, variables, classes, and methods. The editor can also hide or display code blocks on request to help developers keep track of larger-scale projects.

Figure 1: Realbasic is easy to use and offers a rich array of features.

The form editor provides widgets for all three supported platforms. It also has OLE elements to allow developers to embed Microsoft Word and Excel objects. Of course, this will not work in Linux, which does not prevent the tools from being displayed in the toolbox.

A cross hair cursor makes it easier for developers to position and align screen elements by displaying a green line to highlight the edges of other objects, and by snapping the selected element into place when it is at 90 degrees to a reference object (Figure 2).

Figure 2: A cross hair cursor facilitates accurate positioning of GUI elements.

Porting Existing Code

You are probably wondering if it is possible to use existing Visual Basic projects in Realbasic. The answer is a very non-committal, "Basically, yes." The Real Software homepage provides a HOWTO for Visual Basic developers [6] that points out the pitfalls of porting.

Although it is quite simple to modify keywords that are used slightly differently or different data types (Table 2), Realbasic migrators are likely to run into trouble if they draw heavily on ActiveX components and more exotic controls. Realbasic gives you controls that handle the tasks performed by some ActiveX components. The documentation describes these functions, giving you a chance to assess the odds before you decide to purchase. As an example, Realbasic's ListBox does the job handled by the popular Flex Grid in Visual Basic.

Real Software offers a conversion tool [7] (Figure 3) to help developers convert Visual Basic project files, modules, and forms to XML-based Realbasic projects - unfortunately, the tool only runs on Windows. The software discovers and removes syntax errors during this process, but it fails if control labels contain non-standard characters, truncating the names at the first occurrence of the non-standard character. The converter logs any problems it runs into, and possible solutions, in an HTML file (Figure 4). And the new source code contains comments with tips on improving the results.

Figure 3: The Visual Basic converter converts projects to Realbasic format - but only on Windows.

Figure 4: The converter logs problems and solutions in an HTML file.

Databases

The Standard Version of Realbasic only uses an internal database based on SQLite. In contrast to this, the Professional Version uses plugins to support access to MySQL, MS SQL, and MS Access databases. To support development of more interfaces, Realsoftware provides a Plugin Development Kit free of charge at [8]. As SQL is the preferred query language, applications developed with the internal database should also work with other back-ends.

If you are moving from Visual Basic to Realbasic, you do not need to worry about the differences in SQL dialects; the conversion program takes care of that.

Conclusions

Realbasic allows developers to port Visual Basic applications to Linux with very little effort - however, you will probably need Windows to run the converter. If you do not draw heavily on ActiveX controls, your own controls, or controls from toolboxes, you should be able to migrate your Visual Basic projects without too many changes. Your programs should then run on Linux and Windows, Mac OS X, and even the legacy Mac OS.

INFO
[1] Gambas: http://gambas.sourceforge.net
[2] HBasic: http://hbasic.sourceforge.net
[3] WXBasic: http://wxbasic.sourceforge.net
[4] KBasic: http://www.kbasic.org
[5] Realbasic: http://www.realbasic.com
[6] Howto for Visual Basic programmers: http://www.realbasic.com/support/whitepapers/portingvisualbasic
[7] Visual Basic converter: http://highspeed.realsoftware.com/REALbasic55/VBPC.zip
[8] Realbasic Plugin SDK: http://highspeed.realsoftware.com/REALbasic2005r4/PluginsSDK.zip