pro17
PASCAL VISUAL_VBA EXCEL sintassi per variabili booleane
BOOLEAN con PASCAL
program pro3; uses crt; var a,b,c,d:integer; conferma:boolean; begin clrscr; a:=10; b:=50; c:=100; d:=200; (*variabili boolean *) if a>b then writeln(a-b); if a<b then writeln(b-a); if a>b then writeln(a-b) else writeln(b-a); if a>=b then writeln(a+b) else writeln(b-a); if ((b<a) or ( c<d)) then writeln(a+b) else writeln(a*b); if ((a<b) and (c>d)) then writeln(a+b) else writeln(a*b); if not a>b then writeln(b-a) else writeln(a-b); (* uso di True e di False nei test di controllo *) conferma:=false; if a<b then conferma:=true; if conferma then writeln(a*10); conferma:=false; if a>b then conferma:=true; begin if conferma then writeln(a*1) else writeln(b*5); end; readln; end.
ritorna
VISUAL BASIC e VBA
End SubPrivate Sub CommandButton1_Click() Dim a, b, c, d As Integer Dim conferma As Boolean a = Cells(1, 1) b = Cells(1, 2) c = Cells(1, 3) d = Cells(1, 4) If a > b Then Cells(2, 1) = a - b End If If a < b Then Cells(2, 2) = b - a End If If a >= b Then Cells(2, 3) = a - b End If If a > b Then Cells(3, 1) = a - b Else Cells(3, 2) = b - a End If If a < b And c < d Then Cells(4, 1) = a * 10 Else Cells(4, 2) = a * 100 End If If a < b Or c > d Then Cells(5, 1) = a * 5 Else Cells(5, 2) = a * 8 End If conferma = False If a < b Then conferma = True If conferma Then Cells(6, 1) = a * a End If End If conferma = False If a > b Then conferma = True If conferma Then Cells(7, 1) = a * a End If Else Cells(7, 2) = b * a End If end sub
A | B | C | D | |
1 | 10 | 50 | 100 | 200 |
2 | 40 | |||
3 | 40 | |||
4 | 100 | |||
5 | 50 | |||
6 | 100 | |||
7 | 500 | |||
8 |
VISUAL BASIC boolean
Private Sub CommandButton1_Click()
Dim a, b, c, d As Integer
Dim conferma As Boolean
a = 10
b = 50
c = 100
d = 200
Label1.Caption = a
Label2.Caption = b
Label3.Caption = c
Label4.Caption = d
If a > b Then
Label5.Caption = a - b
End If
If a < b Then
Label6.Caption = b - a
End If
If a >= b Then
Label7.Caption = a - b
End If
If a > b Then
Label8.Caption = a - b
Else
Label9.Caption = b - a
End If
If a < b And c
< d Then
Label10.Caption = a * 10
Else
Label11.Caption = a * 100
End If
If a < b Or c > d Then
Label12.Caption = a * 5
Else
Label13.Caption = a * 8
End If
conferma = False
If a < b Then
conferma = True
If conferma Then
Label14.Caption = a * a
End If
End If
conferma = False
If a > b Then
conferma = True
If conferma Then
Label15.Caption = a * a
End If
Else
Label16.Caption = b * a
End If
End Sub
label1 | label2 | label3 | label4 | label5 | label6 |
label7 | label8 | label9 | label10 | label1 | label12 |
label13 | label14 | label15 | label16 | PULSANTE |
Booleani con EXCEL
10 50 100 200 =SE(A1>B1;A1-B1;B1-A1) =SE(A1<B1;B1-A1;"") =SE(A1>=B1;A1-B1;B1-A1) =SE(A1>B1;A1-B1;B1-A1) =SE(E(A1<B1;C1<D1;A1*10);A1*100) =SE(O(A1<B1;C1>D1);A1*5;A1*8) =E(A1<B1;C1<D1) =E(A1>B1;C1<D1) =NON(A1<B1) =NON(A1>B1) =SE(A11;1;0) =SE(A10;1;0)