erstellt  16.12.2015
Rechnen
Der Inhalt einer String Variablen kann nicht direkt für Rechen Operationen verwendet werden, es ist also erforderlich das eine Stringvariable erst in eine Variable anderen Typen umgewandelt werden muss.
Ist z.B. folgender String vorhanden

Dim  S as String * 10
Dim  T as Integer

S= 123456
so muss dieser String folgendermaßen gewandelt werden um damit zu rechnen.

T = Val(S)
Print T






 
Variable
Operation
Ergebnis
Richtiges Ergebnis
A=100
Dim A as Word
A
100
100
Dim B as Word
B=A+10
110
110
Dim C as Word
C=A*166
16600
16600
Dim D as Word
D=A-127
65509
-27
Dim E as Word
E=A/132
0
0,7575
A=100
Dim A as Integer
A
100
100
Dim B as Integer
B=A+10
110
110
Dim C as Integer
C=A*166
16600
16600
Dim D as Integer
D=A-127
-27
-27
Dim E as Integer
E=A/132
0
0,7575
A=100
Dim A as Long
A 100
100
Dim B as Long B=A+10 110
110
Dim C as Long C=A*166 16600
16600
Dim D as Long D=A-127 -27
-27
Dim E as Long E=A/132 00
0,7575
A=100
Dim A as Single
A
100.0
100
Dim B as Single B=A+10
110.0
110
Dim C as Single C=A*166
16600.0
16600
Dim D as Single D=A-127
-27.0
-27
Dim E as Single E=A/132
0.7575
0,7575




A=0
Dim A as Single A
0,0
0
Dim B as Single B=A+10 10,0
10
Dim C as Single C=A*166 0,0
0
Dim D as Single D=A-127 -127.0
-127
Dim E as Single E=A/132 0.00.0
0
A=1
Dim A as Single A 1.0
1
Dim B as Single B=A+10 11.0
11,0
Dim C as Single C=A*166 166.0
166
Dim D as Single D=A-127 -126.0
-126
Dim E as Single E=A/132 0.007575....
0,00757








Aktualisiert 27.12.2015