Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Button5 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button3 = New System.Windows.Forms.Button
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.Button5 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(0, 0)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(128, 40)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Carica Matrice"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(0, 40)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(128, 40)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Visualizza Matrice"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(128, 0)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(208, 200)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(336, 24)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(224, 20)
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = ""
'
'Label1
'
Me.Label1.BackColor = System.Drawing.SystemColors.Control
Me.Label1.Location = New System.Drawing.Point(336, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(224, 24)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Totale:"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(336, 48)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(224, 32)
Me.Button3.TabIndex = 5
Me.Button3.Text = "Totale"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(336, 104)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(224, 20)
Me.TextBox3.TabIndex = 7
Me.TextBox3.Text = ""
'
'Label2
'
Me.Label2.BackColor = System.Drawing.SystemColors.Control
Me.Label2.Location = New System.Drawing.Point(336, 88)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(224, 24)
Me.Label2.TabIndex = 8
Me.Label2.Text = "Massimo:"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(336, 144)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(224, 20)
Me.TextBox4.TabIndex = 9
Me.TextBox4.Text = ""
'
'Label3
'
Me.Label3.BackColor = System.Drawing.SystemColors.Control
Me.Label3.Location = New System.Drawing.Point(336, 128)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(224, 24)
Me.Label3.TabIndex = 10
Me.Label3.Text = "Minimo:"
'
'Button5
'
Me.Button5.Location = New System.Drawing.Point(336, 168)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(224, 32)
Me.Button5.TabIndex = 11
Me.Button5.Text = "Max e Min "
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(568, 207)
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label2)
Me.Name = "Form1"
Me.Text = "Matrici"
Me.ResumeLayout(False)
End Sub
#End Region
Dim matrice(50, 50) As Double
Dim vet(250)
Dim k
Dim i As Integer
Dim j As Integer
Dim c As Integer
Dim r As Integer
Dim s As Double
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
r = Val(InputBox("Inserire Il Numero Di Righe", "Inserisci"))
c = Val(InputBox("Inserire Il Numero Di Colonne", "Inserisci"))
For i = 1 To r
For j = 1 To c
matrice(i, j) = Val(InputBox("Inserisci il valore di riga" & CStr(i) & " e di Colonna " & CStr(j)))
s = s + matrice(i, j)
vet(i) = vet(i) + matrice(i, j)
Next j
Next i
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For i = 1 To r
For j = 1 To c
TextBox1.Text = TextBox1.Text + CStr(matrice(i, j)) & " "
Next j
TextBox1.Text = TextBox1.Text + vbNewLine
Next i
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox2.Text = Val(s)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
For i = 1 To r
For j = 1 To c
vet(k) = matrice(i, j)
k = k + 1
Next j
Next i
For i = 1 To r
For j = 1 To c
matrice(i, j) = vet(k)
k = k + 1
TextBox1.Text = TextBox1.Text + CStr(matrice(i, j)) & " "
Next j
TextBox1.Text = TextBox1.Text + vbNewLine
Next i
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim max, min
For i = 1 To r
For j = 1 To c
If i = 1 And j = 1 Then
max = matrice(i, j)
min = matrice(i, j)
End If
If matrice(i, j) > max Then
max = matrice(i, j)
End If
If matrice(i, j) < min Then
min = matrice(i, j)
End If
Next
Next
TextBox3.Text = CStr(max)
TextBox4.Text = CStr(min)
End Sub
End Class