Como puedo pasarlo a ciclo for ?
gracias
Código
Public Class Form1 Dim a(2, 2) As Integer Dim sum1, sum2, sum3, sum4, sum5, sum6, sum7, sum8 As Integer Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click a(0, 0) = TextBox1.Text a(0, 1) = TextBox2.Text a(0, 2) = TextBox3.Text a(1, 0) = TextBox4.Text a(1, 1) = TextBox5.Text a(1, 2) = TextBox6.Text a(2, 0) = TextBox7.Text a(2, 1) = TextBox8.Text a(2, 2) = TextBox9.Text sum1 = a(0, 0) + a(0, 1) + a(0, 2) sum2 = a(1, 0) + a(1, 1) + a(1, 2) sum3 = a(2, 0) + a(2, 1) + a(2, 2) sum4 = a(0, 0) + a(1, 0) + a(2, 0) sum5 = a(0, 1) + a(1, 1) + a(2, 1) sum6 = a(0, 2) + a(1, 2) + a(2, 2) sum7 = a(0, 0) + a(1, 1) + a(2, 2) sum8 = a(0, 2) + a(1, 1) + a(2, 0) If sum1 = 15 And sum2 = 15 And sum3 = 15 And sum4 = 15 And sum5 = 15 And sum6 = 15 And sum7 = 15 And sum8 = 15 Then If a(0, 0) <> a(0, 1) Or a(0, 0) <> a(0, 2) Or a(0, 0) <> a(1, 0) Or a(0, 0) <> a(1, 1) Or a(0, 0) <> a(1, 2) Or a(0, 0) <> a(2, 0) Or a(0, 0) <> a(2, 1) Or a(0, 0) <> a(2, 2) Then If a(0, 1) <> a(0, 0) Or a(0, 1) <> a(0, 2) Or a(0, 1) <> a(1, 0) Or a(0, 1) <> a(1, 1) Or a(0, 1) <> a(1, 2) Or a(0, 1) <> a(2, 0) Or a(0, 1) <> a(2, 1) Or a(0, 1) <> a(2, 2) Then If a(0, 2) <> a(0, 0) Or a(0, 1) <> a(0, 2) Or a(0, 2) <> a(1, 0) Or a(0, 2) <> a(1, 1) Or a(0, 2) <> a(1, 2) Or a(0, 2) <> a(2, 0) Or a(0, 2) <> a(2, 1) Or a(0, 2) <> a(2, 2) Then If a(1, 0) <> a(0, 0) Or a(0, 1) <> a(1, 0) Or a(0, 2) <> a(1, 0) Or a(1, 0) <> a(1, 1) Or a(1, 0) <> a(1, 2) Or a(1, 0) <> a(2, 0) Or a(1, 0) <> a(2, 1) Or a(1, 0) <> a(2, 2) Then If a(1, 1) <> a(0, 0) Or a(0, 1) <> a(1, 1) Or a(0, 2) <> a(1, 1) Or a(1, 0) <> a(1, 1) Or a(1, 1) <> a(1, 2) Or a(1, 1) <> a(2, 0) Or a(1, 1) <> a(2, 1) Or a(1, 1) <> a(2, 2) Then If a(1, 2) <> a(0, 0) Or a(0, 1) <> a(1, 2) Or a(0, 2) <> a(1, 2) Or a(1, 0) <> a(1, 2) Or a(1, 1) <> a(1, 2) Or a(1, 2) <> a(2, 0) Or a(1, 2) <> a(2, 1) Or a(1, 2) <> a(2, 2) Then If a(2, 0) <> a(0, 0) Or a(0, 1) <> a(2, 0) Or a(0, 2) <> a(2, 0) Or a(1, 0) <> a(2, 0) Or a(1, 1) <> a(2, 0) Or a(1, 2) <> a(2, 0) Or a(2, 0) <> a(2, 1) Or a(2, 0) <> a(2, 2) Then If a(2, 1) <> a(0, 0) Or a(0, 1) <> a(2, 1) Or a(0, 2) <> a(2, 1) Or a(1, 0) <> a(2, 1) Or a(1, 1) <> a(2, 1) Or a(1, 2) <> a(2, 1) Or a(2, 0) <> a(2, 1) Or a(2, 1) <> a(2, 2) Then If a(2, 2) <> a(0, 0) Or a(0, 1) <> a(2, 2) Or a(0, 2) <> a(2, 2) Or a(1, 0) <> a(2, 2) Or a(1, 1) <> a(2, 2) Or a(1, 2) <> a(2, 2) Or a(2, 0) <> a(2, 2) Or a(2, 1) <> a(2, 2) Then MsgBox("es un cuadro mágico") End If Else MsgBox("no es un cuadro mágico hay numeros repetidos") End If Else MsgBox("no es un cuadro mágico hay numeros repetidos") End If Else MsgBox("no es un cuadro mágico hay numeros repetidos") End If Else MsgBox("no es un cuadro mágico hay numeros repetidos") End If Else MsgBox("no es un cuadro mágico hay numeros repetidos") End If Else MsgBox("no es un cuadro mágico hay numeros repetidos") End If Else MsgBox("no es un cuadro mágico hay numeros repetidos") End If Else MsgBox("no es un cuadro mágico hay numeros repetidos") End If Else If a(0, 0) <> a(0, 1) Or a(0, 0) <> a(0, 2) Or a(0, 0) <> a(1, 0) Or a(0, 0) <> a(1, 1) Or a(0, 0) <> a(1, 2) Or a(0, 0) <> a(2, 0) Or a(0, 0) <> a(2, 1) Or a(0, 0) <> a(2, 2) Then If a(0, 1) <> a(0, 0) Or a(0, 1) <> a(0, 2) Or a(0, 1) <> a(1, 0) Or a(0, 1) <> a(1, 1) Or a(0, 1) <> a(1, 2) Or a(0, 1) <> a(2, 0) Or a(0, 1) <> a(2, 1) Or a(0, 1) <> a(2, 2) Then If a(0, 2) <> a(0, 0) Or a(0, 1) <> a(0, 2) Or a(0, 2) <> a(1, 0) Or a(0, 2) <> a(1, 1) Or a(0, 2) <> a(1, 2) Or a(0, 2) <> a(2, 0) Or a(0, 2) <> a(2, 1) Or a(0, 2) <> a(2, 2) Then If a(1, 0) <> a(0, 0) Or a(0, 1) <> a(1, 0) Or a(0, 2) <> a(1, 0) Or a(1, 0) <> a(1, 1) Or a(1, 0) <> a(1, 2) Or a(1, 0) <> a(2, 0) Or a(1, 0) <> a(2, 1) Or a(1, 0) <> a(2, 2) Then If a(1, 1) <> a(0, 0) Or a(0, 1) <> a(1, 1) Or a(0, 2) <> a(1, 1) Or a(1, 0) <> a(1, 1) Or a(1, 1) <> a(1, 2) Or a(1, 1) <> a(2, 0) Or a(1, 1) <> a(2, 1) Or a(1, 1) <> a(2, 2) Then If a(1, 2) <> a(0, 0) Or a(0, 1) <> a(1, 2) Or a(0, 2) <> a(1, 2) Or a(1, 0) <> a(1, 2) Or a(1, 1) <> a(1, 2) Or a(1, 2) <> a(2, 0) Or a(1, 2) <> a(2, 1) Or a(1, 2) <> a(2, 2) Then If a(2, 0) <> a(0, 0) Or a(0, 1) <> a(2, 0) Or a(0, 2) <> a(2, 0) Or a(1, 0) <> a(2, 0) Or a(1, 1) <> a(2, 0) Or a(1, 2) <> a(2, 0) Or a(2, 0) <> a(2, 1) Or a(2, 0) <> a(2, 2) Then If a(2, 1) <> a(0, 0) Or a(0, 1) <> a(2, 1) Or a(0, 2) <> a(2, 1) Or a(1, 0) <> a(2, 1) Or a(1, 1) <> a(2, 1) Or a(1, 2) <> a(2, 1) Or a(2, 0) <> a(2, 1) Or a(2, 1) <> a(2, 2) Then If a(2, 2) <> a(0, 0) Or a(0, 1) <> a(2, 2) Or a(0, 2) <> a(2, 2) Or a(1, 0) <> a(2, 2) Or a(1, 1) <> a(2, 2) Or a(1, 2) <> a(2, 2) Or a(2, 0) <> a(2, 2) Or a(2, 1) <> a(2, 2) Then MsgBox("no es un cuadro mágico ") Else MsgBox("no es un cuadro mágico hay numeros repetidos") End If End If End If End If End If End If End If End If End If End If End Sub End Class