Clases Ingeniero Julian Las ultimas clases del ingeniero Julian, hemos tenido una experiencia usando vectores, y matrices, he aqui un ejercicio, que nos puso, como ayuda para para la evaluacion:
aqui esta el codigo: Dim nota(,) As String Dim T, I, J, filas, columnas As Int32 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = "" Or TextBox2.Text = "" Then MsgBox("Digite los datos completos") Else filas = TextBox1.Text - 1 columnas = TextBox2.Text + 1 ReDim nota(filas, columnas) End If TextBox1.Text = "" TextBox2.Text = "" End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If TextBox3.Text = "" Then MsgBox("Digite los datos") End If If I > filas Then MsgBox("matriz Llena") Else If J <> 0 Then MsgBox("solo un nombre, termine de ingresar notas") Else nota(I, J) = TextBox3.Text
J=J+1 End If End If TextBox3.Text = "" End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If TextBox4.Text = "" Then MsgBox("Digite los datos") End If If TextBox4.Text > 5 Then MsgBox("Nota Erronea, La nota debe estar entre 0 y 5") End If If J = 0 And I < columnas - 1 Then MsgBox("escriba el nombre") Else If I < filas + 1 Then nota(I, J) = TextBox4.Text T = T + nota(I, J) J=J+1 If J = columnas Then nota(I, J) = T / (columnas - 1) T=0 I=I+1 J=0 End If Else MsgBox("matriz Llena") End If End If TextBox4.Text = "" End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click For x = 0 To filas For x2 = 0 To columnas TextBox5.Text = TextBox5.Text + CStr(nota(x, x2)) + " " Next x2 TextBox5.Text = TextBox5.Text + vbCrLf Next x End Sub Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If Char.IsDigit(e.KeyChar) Then e.Handled = False ElseIf Char.IsControl(e.KeyChar) Then e.Handled = False
Else e.Handled = True End If End Sub Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress If Char.IsDigit(e.KeyChar) Then e.Handled = False ElseIf Char.IsControl(e.KeyChar) Then e.Handled = False Else e.Handled = True End If End Sub Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress If Char.IsDigit(e.KeyChar) Then e.Handled = False ElseIf Char.IsControl(e.KeyChar) Then e.Handled = False Else e.Handled = True End If End Sub Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress If Char.IsLetter(e.KeyChar) Then e.Handled = False ElseIf Char.IsControl(e.KeyChar) Then e.Handled = False ElseIf Char.IsSeparator(e.KeyChar) Then e.Handled = False Else e.Handled = True End If End Sub End Class