Archives
 
 
 
  Special
 
 
 
  About Us
 
 
 

Newsletter
Free E-mail Newsletter from BYTE.com

 
    
           
Visit the home page Browse the four-year online archive Download platform-neutral CPU/FPU benchmarks Find information for advertisers, authors, vendors, subscribers Request free information on products written about or advertised in BYTE Submit a press release, or scan recent announcements Talk with BYTE's staff and readers about products and technologies

ArticlesConvert Visual Basic to Java


March 1997 / Javatalk / Convert Visual Basic to Java

Applet Designer turns Visual Basic programs into Java source code.

Rick Grehan

I knew this would happen. I knew someone would try to find a way to turn Visual Basic applications into Java applications. Applet Designer from TVObjects is the first attempt at this I've seen. I suspect there'll be more.

Applet Designer actually lets you build Java applets from within the Visual Basic integrated development environment (IDE). The tool operates as a VB plug-in; when you fire up Visual Basic, Applet Designer's floating toolbar appears. With Applet Designer, you can use the Visual Basic IDE to constru 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


HotBYTEs
 - information on products covered or advertised in BYTE


Rick Grehan is a senior technical editor for BYTE reviews and coauthor of The Client/Server Toolkit for C/C++ Programmers. You can reach him at rick_g@bix .com.

Up to the Javatalk section contentsSearchSend a comment on this articleSubscribe to BYTE or BYTE on CD-ROM  
Flexible C++
Matthew Wilson
My approach to software engineering is far more pragmatic than it is theoretical--and no language better exemplifies this than C++.

more...

BYTE Digest

BYTE Digest editors every month analyze and evaluate the best articles from Information Week, EE Times, Dr. Dobb's Journal, Network Computing, Sys Admin, and dozens of other CMP publications—bringing you critical news and information about wireless communication, computer security, software development, embedded systems, and more!

Find out more

BYTE.com Store

BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than 8 years of BYTE.
 
The Best of BYTE Volume 1: Programming Languages
The Best of BYTE
Volume 1: Programming Languages
In this issue of Best of BYTE, we bring together some of the leading programming language designers and implementors...

Copyright © 2005 CMP Media LLC, Privacy Policy, Your California Privacy rights, Terms of Service
Site comments: webmaster@byte.com
SDMG Web Sites: BYTE.com, C/C++ Users Journal, Dr. Dobb's Journal, MSDN Magazine, New Architect, SD Expo, SD Magazine, Sys Admin, The Perl Journal, UnixReview.com, Windows Developer Network