VBS Ejercicio #2
Crear un programa que permita ingresar matriz NxM y pueda verificar la diagonal si son iguales a 1
'Definir Variables en el Formulario.Dim a, b As Integer
Dim fila, columna As Byte
'1er boton Agregar.
Dim i As Byte
fila = Val(Me.TextBox1.Text)
columna = Val(Me.TextBox2.Text)
Me.DataGrid.ColumnCount = columna
Me.DataGrid.RowCount = fila
Me.DataGrid.RowHeadersWidth = 70
For i = 0 To columna - 1
Me.DataGrid.Columns(i).Width = 40
Me.DataGrid.Columns(i).HeaderText = i + 1
Next
For i = 0 To fila - 1
Me.DataGrid.Rows(i).HeaderCell.Value = (i + 1).ToString
Next
'2do Boton Diagonal.
Dim cont = 0
Dim z = 0
For i = 0 To fila - 1
For j = 0 To columna - 1
If (i = j) Then
If Me.DataGrid.Rows(i).Cells(j).Value = 1 Then
cont += 1
End If
End If
Next
Next
If (cont = columna) Then
TextBox3.Text = "LOS NUMEROS DE LA DIAGONAL SON IGUAL A 1"
Else
TextBox3.Text = "LOS NUMEROS DE LA DIAGONAL NO SON IGUAL A 1"
End If