Keywords Compared in Different Languages
Purpose |
Visual Basic |
Visual J# |
C++ |
C# NEW |
JScript |
Visual FoxPro |
Create a new object |
new |
NEWOBJECT() |
||||
|
n/a |
CoCreateInstance() (for COM objects) |
|
new ActiveXObject() |
CREATEOBJECT() |
|
Refer to the current object |
Me3 |
this |
this; thisform |
|||
Initialize a variable where it is declared |
Dim x As Long = 5 Dim c As New Car(FuelTypeEnum.Gas) |
int x = 5; //or initialized by constructor C c(10); |
int x=5; |
// initialize to a value: int x = 123; // or use default constructor: int x = new int(); |
var x = 5 var y : car = new car() |
LOCAL x x = 5 |
Test for an object variable that does not refer to an object |
pObj == null |
pobj == NULL |
obj == null |
obj == undefined obj == null |
VARTYPE(obj)==”O” |
|
Value of an object variable that does not refer to an object |
null |
n/a |
null undefined |
.F. |
Purpose |
Visual Basic |
Visual J# |
C++ |
C# NEW |
JScript |
Visual FoxPro |
Refer to a base class |
MyBase NEW |
super |
super NEW |
BaseClass property; ParentClass property; DODEFAULT(); Class::Member |
||
Declare a class |
Class NEW <implementation> |
class |
class NEW |
DEFINE CLASS MyClass AS <ParentClass> |
||
Specify the events for which an event procedure will be called |
Handles NEW (Event procedures can still be associated with a WithEvents variable by naming pattern.) |
n/a |
n/a |
n/a |
n/a |
BINDEVENTS() |
Purpose |
Visual Basic |
Visual J# |
C++ |
C# NEW |
JScript |
Visual FoxPro |
Decision structure |
switch, case, break, default |
switch, case, default, goto, break |
CASE; ICASE() |
|||
Decision structure (if ... then) |
if, else |
IF ... ENDIF; IIF() |
||||
Loop
structure |
for, break |
FOR (clauses), FOR ... ENDFOR, Continue, NEXT |
Purpose |
Visual Basic |
Visual J# |
C++ |
C# NEW |
JScript |
Visual FoxPro |
Initialize an array |
int[] x = {1,2,3,4,5}; |
var x : int[] = [1, 2, 3, 4, 5], var arr = new Array(1, 2, 3, 4, 5)] |
x[1] = 1 X[2] = 2 |
Purpose |
Visual Basic |
Visual J# |
C++ |
C# NEW |
JScript |
Visual FoxPro |
Declare and raise an event |
Use the java.awt.Event class or
|
n/a |
n/a |
RAISEEVENT() |
Programming Concepts Compared in Different Languages with Code Examples
IF nCnt < nMax
nTot = nTot * nCnt
nCnt = nCnt + 1
ELSE
nTot = nTot * nCnt
nCnt = nCnt - 1
ENDIF
oBase = newobject ("BaseCls")
oDerived = newobject ("DerivedCls")
?oBase.Z
?oDerived.Z
DEFINE CLASS BaseCls AS SESSION
PROTECTED Z && The element to be hidden outside of class
Z = 100
ENDDEFINE
DEFINE CLASS DerivedCls AS BaseCls
HIDDEN Z && The hiding element from subclasses
Z = “*”
ENDDEFINE
ABC(x)
–or–
DO ABC WITH (x)
ABC(@x)
–or–
DO ABC WITH x
TRY
IF x = 0
THROW "x equals zero"
ELSE
THROW "x does not equal zero"
ENDIF
CATCH TO err
MESSAGEBOX("Error: " + err.UserValue)
FINALLY
MESSAGEBOX("Executing finally block.")
ENDTRY
MyObj = null
-or-
MyObj = .NULL.
LOCAL ltDateTime AS DateTime
ltDateTime = DATETIME(2001, 4, 12, 22, 16, 49)
Data Types Compared in Different Languages
Storage size |
Visual Basic |
Visual J# |
Visual C++ |
C# NEW |
JScript |
Visual FoxPro |
(varies) |
String NEW (.NET Framework class) |
java.lang.String or System.String |
n/a |
String NEW |
VarChar |
|
1 byte |
byte |
BYTE, bool |
byte NEW |
Integer |
||
2 bytes |
boolean |
VARIANT_BOOL |
boolean NEW |
Logical |
||
4 bytes |
float |
float NEW |
Float |
|||
8 bytes |
double |
double NEW |
Double |
Operators Compared in Different Languages
For details about operators in this language |
See |
||||||
Visual FoxPro |
|||||||
|
Visual Basic |
Visual J# |
C++ |
C# NEW |
JScript |
Visual FoxPro |
|
Modulus (division returning only the remainder) |
Mod |
% |
% |
% |
% (also works with floating point) |
%, Mod |
|
Not equal |
<> |
!= |
!= |
!= |
!= |
<>,` #, != |
|
Compare strings |
= |
String.equals() |
(There are functions to compare and concatenate strings) |
== -or-String.Equals() |
== |
=, == |
|
Shortcircuited Boolean AND |
AndAlso |
&& |
&& |
&& |
&& |
AND, .AND. |
|
Array element |
() |
[ ] |
[ ] |
[ ] |
[ ] |
[ ], () |
|
Logical-NOT |
Not |
! |
! |
! |
! |
!, NOT, .NOT. |
|
Bitwise-inclusive-OR |
Or |
| |
| |
| |
| |
BITOR() |
|
Logical-AND |
And |
&& |
&& |
&& |
&& |
AND, .AND. |
|
Logical-OR |
Or |
|| |
|| |
|| |
|| |
OR, .OR. |
|
Controls and Programmable Objects Compared in Different Languages and Libraries
Visual Basic 6.0 object |
Windows Forms control NEW |
ASP.NET server control NEW |
HTML server control NEW |
MFC class |
ATL class |
Visual FoxPro object |
Animation |
Images on controls support animated GIFs |
n/a |
n/a |
n/a |
Image |
|
PictureBox |
n/a |
Image |