ct a form and convert the visual content of that form into corresponding Java code. Applet Designer will also translate VB programs to Java programs.
Applet Designer translates at the source-code level; that is, Visual Basic source to Java source. There are caveats -- lots, in fact -- to the source-to-source translation route. The alternative path is to generate bytecode, which is the equivalent of machine-language code for the Java virtual machine (VM). Bytecode is portable, as it runs on any Java VM-enabled platform. Source code is also potentially portable, but you need to compile it with a Java compiler.
One caveat to the source-code approach involves type translation. Applet Designer can turn most, but not all, VB data types into corresponding Java data types. Applet Designer is unable to convert VB's object or variant data types. Ouch.
There's also the matter of exception handling, which in VB appears as
ON ERROR GOTO
statements, while Java uses the
try...catch
block. Ain't no way you're going to get a smooth translation there. Big ouch. I discussed this with the people at TVObjects, and they suggested ways of moving
the error-handling code into a function/subroutine, then inserting the corresponding method in a
try...catch
clause. Some jobs require a crowbar, I suppose.
Other snares exist. Applet Designer can't handle implicit variables. There are restrictions on the
Select...Case
control structure. And Applet Designer can't swallow
EXIT
instructions. That last one really hurts.
But it would be incorrect to characterize Applet Designer as nothing more than a source-code translator. As I said at the outset, Applet Designer can also convert the visual content of a form into corresponding Java code. If you turn it loose on a VB form, Applet Designer will snoop out the buttons, checkboxes, textboxes, and other elements that populate the form. It then builds Java source code containing the equivalent objects. Applet Designer will even build event-handling code and correctly wire in the created objects. The version of Applet Designer I tested (version 1.0) recognized about 10 of the standard
VB controls.
There are advantages to the source-translation route. Because Applet Designer emits Java source, rather than bytecode, the level of reuseability of generated code is higher. For example, you can use the source to document the code's interfaces. This documentation could be useful to you (especially if you have a poor memory) as well as to other Java programmers.
Happily, version 1.0 is the first in what TVObjects hopes will be a series of ever-improving editions. Some of the shortcomings should be addressed in a new release that was slated for mid-January availability. The new 1.1 release will expand the number of VB elements it can translate. For example, Applet Designer 1.1 will properly handle the
EXIT
statement, recognize horizontal and vertical scroll bars, translate
Do...Loop
statements, and provide full-featured
MsgBox
and
InputBox
functions.
As I write this, two editions are available: standard ($147) and professional ($497). The professional
edition includes all the features I mentioned above, plus support for Java database connectivity (JDBC). The enterprise edition (just entering beta at press time) will add the ability to convert distributed VB applications into equivalent distributed Java applications using either Java remote method invocation (RMI) or Java objects that are compliant with the Common Object Request Broker Architecture (CORBA). If TVObjects can do all that, you may be reading about the company again in this column real soon.
Product Information
TVObjects Corp.
Princeton, NJ
Phone: (609) 514-1444
E-mail:
info@tvobjects.com
Internet:
http://www.tvobjects.com