Visual Basic Language

Statements

Supported Unsupported
  • If ... Then ... Else ...
  • If ... Then ... ElseIf ... Else ... End If
  • Select Case
  • Do ... Loop [While | Until]
  • Do [While | Until] ... Loop
  • While ... Wend
  • For ... To ... Next
  • For Each ... In ... Next
  • On Error
  • GoSub
  • With (see notes)
  • Exit For, Exit Do, Exit <ID>, Exit Sub, Exit Function
  • End
  • Let, Set
  • Dim, Public, Private, Const, Static
  • Property Get, Let, Set
  • Type ... End Type
  • Enum ... End Enum
  • Debug.Print
  • GoTo
  • Resume
Notes on With block: If you get an error reported for a line with the '.' (with) operator, it probably means that the with operator was ambiguous in this context. You should try explicitely declaring the entire expression.

Notes: The error handler for an "On Error Goto

Data Types

All data types are supported: Boolean, Byte, Currency, Double, Integer, Long, Single, String, Object, Variant, and User defined types. Arrays of all types are supported.

Notes on Variants: It is recommended that you change all variables not explicitely typed with one of the above types or variables of type Variant to be the explicit type you want before converting to Java. This will allow your Java code to use the built-in data types instead of the Variant class. The Variant class is a little more difficult to work with in Java since all operations on Variants are function calls.

Miscellaneous

Notes on ByRef: Java always passes arguments by value. When we encounter a ByRef argument of a primitive data type that was modified during the function, we change the data type of the argument and the variable from the calling function to a Variant. Objects are always passed as Objects. Their properties can be changed and propagated.

Constants

Most constants are supported.

Operators

  Supported Unsupported
Logical And, Or, Xor, Not Eqv, Imp
Comparison =, <, <, , <=, =, Is Like
Arithmetic ^, *, /, \, Mod, +, -  
Other &, TypeOf In
 

Functions

  Supported Unsupported
Misc. Beep, Choose, Command, DoEvents, IIf, LoadPicture, Me, Optional, QBColor, RGB, Shell, Switch, Unload Alignment, AppActivate, CallByName, Load, ParamArray, SavePicture, SendKeys, Stop, Tab
Conversion CBool, CByte, CCur, CDate, CDbl, CDec, CInt, CLng, CSng, CStr, CVar, CVDate, CVErr, Error, Fix, Hex, Int, Oct, Str, Val, IsArray IsDate, IsEmpty, IsError, IsMissing, IsNull, IsNumeric, IsObject, TypeName, VarType  
DateTime Date, DatePart, DateSerial, DateValue, Day, Hour, Minute, Month, Now, Second, Time, Timer, TimeSerial, TimeValue, Weekday, Year Calendar, Date(set), Time(set)
Files Close, EOF, FileAttr, FileDateTime, FileLen, FreeFile, Input, Kill, LOF, MkDir, RmDir, Seek, Seek ChDir, ChDrive, CurDir, Dir, FileCopy, GetAttr, Loc, Reset, SetAttr, Width,
Database  DAO, RDO, and ADO  
Financial DDB, FV, NPer, Pmt, PV, SLN, SYD IPmt, IRR, MIRR, NPV, PPmt, Rate
Math Abs, Atn, Cos, Exp, Log, Randomize, Rnd, Round, Sin, Sgn, Sqr, Tan  
Input/Output InputBox, MsgBox  
Arrays Array, Lbound, ReDim, UBound  
Strings Asc, AscB, AscW, Chr, ChrB, ChrW, Format, FormatCurrency, FormatDateTime, FormatNumber, FormatPercent, Instr, InstrB, InStrRev, Lcase, Left, LeftB, Len, LenB, Ltrim, Join, Mid, MidB, MonthName, Replace, Right, RightB, Rtrim, Space, Split, StrComp, String, StrReverse, Trim, Ucase, WeekdayName Filter, LSet, RSet, StrConv
Windows API Sleep All Others
 Notes: Use html tag <PARAM NAME=cmd VALUE="your command arguments"> to specify command line args for applets. These are accessed from the VB Command function.

Extensions

The following are extensions that can be used in the VB code that will not work in VB but will be converted to Java to work as they are documented.

Hyperlinks - put the following in the VB code to make the browser navigate from the applet to a new
page or from an application show the URL in a simple browser window:

ShowURL "http://www.diamondedge.com"

Playing a sound file - put the following in the VB code to make the browser play a sound file:

PlaySound "http://www.diamondedge.com/intro.au"

Setting the command line arguments in an applet - put the following in the html code to pass in arguments to your code. It will available from the App.Command property in VB just as you normally access the command-line arguments:

<PARAM NAME=cmd VALUE="your command arguments">

You will notice that a blank line similar to the above has been automatically generated when the application was converted to Java and placed in the proper place.