pro22
gestione matrici
PASCAL
program pro22; uses crt; var matrice:array[1..3,1..3] of integer; a,b :integer; begin clrscr; (* inserimento valori in variabili *) matrice[1,1]:=1; matrice[1,2]:=2; matrice[1,3]:=3; matrice[2,1]:=10; matrice[2,2]:=20; matrice[2,3]:=30; matrice[3,1]:=50; matrice[3,2]:=60; matrice[3,3]:=70; (* visualizza valori della matrice *) for a:=1 to 3 do begin for b:=1 to 3 do writeln(matrice[a,b]); writeln; end; readln; end. RUN e visualizza 1 2 3 10 20 30 50 60 70
VBA per excel creare PULSANTE per istruzioni
PULSANTE |
Private Sub CommandButton1_Click() Dim matrice(2, 2) As Integer Dim r, c As Integer matrice(1, 1) = Cells(4, 1) matrice(1, 2) = Cells(4, 2) matrice(2, 1) = Cells(5, 1) matrice(2, 2) = Cells(5, 2) For r = 1 To 2 For c = 1 To 2 Cells(r, c) = matrice(r, c) Next c Next r End Sub
inserire numeri in celle A4,A5,B4,B5 e cliccare PULSANTE per vedere risultato
A | B | |
1 | 10 | 30 |
2 | 20 | 40 |
3 | ||
4 | 10 | 30 |
5 | 20 | 40 |
VISUAL BASIC creare PULSANTE per istruzioni e 8 caselle label
PULSANTE |
Private Sub CommandButton1_Click() Dim matrice(2, 2) As Integer Dim r, c As Integer matrice(1, 1) = Label1.Caption matrice(1, 2) = Label2.Caption matrice(2, 1) = Label3.Caption matrice(2, 2) = Label4.Caption Label5.Caption = matrice(1, 1) Label6.Caption = matrice(1, 2) Label7.Caption = matrice(2, 1) Label8.Caption = matrice(2, 2) End Sub
scrivere valori in label 1,2,3,4 e visualizzarli in label 5,6,7,8
label1 | label2 | label5 | label6 | |
label3 | label4 | label7 | label8 |
10 | 30 | 10 | 30 | |
20...... | 40..... | 20..... | 40.... |