1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
Option Explicit
Private errorCount As Integer = 0
Private sErr As String = ""
Public Sub main(ByJava args() As String)
Call operatorCheck()
End Sub
Private Sub operatorCheck
Dim obj As Object = New Object
t "a", "&", "b", "a" & "b", "ab", "string concatenation"
t "", "&", "b", "" & "b", "b", "string concatenation"
t "a", "&", "", "a" & "", "a", "string concatenation"
t "Null", "&", "b", Null & "b", "b", "String concatenation"
t "a", "&", "Null", "a" & Null, "a", "String concatenation"
t "Nothing", "&", "b", Nothing & "b", "b", "String concatenation"
t "a", "&", "Nothing", "a" & Nothing, "a", "String concatenation"
t "1", "*", "1", 1*1, 1, "multiply"
' allowed neither in VB6 nor in Jabaco
' t "Null", "*", "1", Null*1, Null, "multiply"
' t "1", "*", "Null", 1*Null, Null, "multiply"
' t "Null", "*", "Null", Null * Null, Null, "multiply"
' t "Nothing", "*", "1", Nothing*1, Nothing, "multiply"
' VB6 grumbles about overflow here
t "20000", "*", "4", 20000 * 4, 80000, "multiply"
' VB6 grumbles about overflow here
t "70000", "*", "70000", 70000 * 70000, 4900000000, "multiply"
' VB6 grumbles about overflow here
t "70000", "*", "70000", 70000.0 * 70000.0, 4900000000, "multiply"
t "70000", "*", "70000", CLng(70000) * CLng(70000), CLng(4900000000), "multiply"
t "1", "+", "1", 1 + 1, 2, "add"
' allowed neither in VB6 nor in Jabaco
' t "Null", "+", "1", Null + 1, Null, "add"
t "1", "-", "1", 1 - 1, 0, "subtract"
' allowed neither in VB6 nor in Jabaco
' t "Null", "-", "1", Null - 1, Null, "subtract"
t "20", "/", "80", 20 / 80, 0.25, "float divide"
t "20", "", "80", 20 \ 80, 0, "integer divide"
t "2", "^", "10", CLng(2 ^ 10), CLng(1024), "power"
t "25", "^", "0.5", CLng(25 ^ 0.5), CLng(5), "power"
t "2", "^", "-1", 2 ^ -1, 0.5, "power"
t "a", "=", "b", "a" = "b", False, "equals"
t "a", "=", "a", "a" = "a", True, "equals"
t "a", "<>", "b", "a" <> "b", True, "unequals"
t "a", "<>", "a", "a" <> "a", False, "equals"
t "12", "and", "10", 12 And 10, 8, "bitwise and"
t "false", "and", "true", False And True, False, "and"
t "true", "and", "false", True And False, False, "and"
t "false", "and", "false", False And False, False, "and"
t "true", "and", "true", True And True, True, "and"
' allowed in VB6 but not implemented in Jabaco
' t "Obj", "is", "Obj", obj Is obj, True, "is comparison"
' t "a", "like", "[b-z]", "a" Like "[b-z]", False, "like comparison"
' t "12", "eqv", "10", 12 eqv 10, -7, "eqv equivalence"
' t "12", "imp", "10", 12 imp 10, -5, "imp implication"
t "10", "mod", "5", 10 Mod 5, 0, "mod modulo"
t "10", "mod", "3", 10 Mod 3, 1, "mod modulo"
t "12", "mod", "4.3", round(12 Mod 4.3, 2), round(0.00, 2), "mod modulo"
t "12.6", "mod", "5", round(12.6 Mod 5, 2), round(3.00, 2), "mod modulo"
t "12", "not", "", Not 12, -12 - 1, "bitwise not"
t "10", "not", "", Not 10, -10 - 1, "bitwise not"
t "12", "or", "10", 12 Or 10, 14, "bitwise or"
t "false", "or", "true", False Or True, True, "or"
t "true", "or", "false", True Or False, True, "or"
t "false", "or", "false", False Or False, False, "or"
t "true", "or", "true", True Or True, True, "or"
t "12", "xor", "10", 12 XOr 10, 6, "bitwise xor"
t "false", "xor", "true", False XOr True, True, "xor"
t "true", "xor", "false", True XOr False, True, "xor"
t "false", "xor", "false", False XOr False, False, "or"
t "true", "xor", "true", True XOr True, False, "xor"
If ErrorCount > 0 Then
msgbox "Errors: " & ErrorCount & vbcrlf & "-------------" & sErr
End If
End Sub
Private Sub t(lVal As String, op As String, rVal As String, res As String, resComp As String, remark As String)
Dim s As String
If res <> resComp Then
s = lVal & " " & op & " " & rVal & " = " & res & " <> " & resComp & " " & remark
sErr = sErr & vbCrLf & s
errorCount = errorCount + 1
End If
End Sub
|