Public Class Form1
Dim chk(8) As Integer
Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown, Button2.MouseDown, Button3.MouseDown, Button4.MouseDown, Button5.MouseDown, Button6.MouseDown, Button7.MouseDown, Button8.MouseDown, Button9.MouseDown, Button10.MouseDown
sender.DoDragDrop(sender.Text, DragDropEffects.Copy)
End Sub
Private Sub Buttons_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Button11.DragDrop, Button12.DragDrop, Button13.DragDrop, Button14.DragDrop, Button15.DragDrop, Button16.DragDrop, Button17.DragDrop, Button18.DragDrop, Button19.DragDrop
sender.text &= e.Data.GetData(DataFormats.Text).ToString
End Sub
Private Sub Buttons_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Button11.DragEnter, Button12.DragEnter, Button13.DragEnter, Button14.DragEnter, Button15.DragEnter, Button16.DragEnter, Button17.DragEnter, Button18.DragEnter, Button19.DragEnter
e.Effect = DragDropEffects.Copy
End Sub
Private Sub Button12_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button11.MouseDown, Button12.MouseDown, Button13.MouseDown, Button14.MouseDown, Button15.MouseDown, Button16.MouseDown, Button17.MouseDown, Button18.MouseDown, Button19.MouseDown
sender.DoDragDrop(sender.Text, DragDropEffects.Copy)
If Val(sender.text) <> 0 Then
sender.text = Val(sender.text \ 10)
If Val(sender.text) = 0 Then
sender.text = ""
End If
End If
End Sub
Private Sub Button20_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Button20.DragDrop, Button21.DragDrop
sender.text = e.Data.GetData(DataFormats.Text).ToString
End Sub
Private Sub Button20_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Button20.DragEnter, Button21.DragEnter
e.Effect = DragDropEffects.Copy
End Sub
Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
Dim i, j As Integer
Dim myctrl As Control
i = 0
For Each myctrl In Panel1.Controls
chk(i) = Val(myctrl.Text)
i += 1
Next
For i = 0 To 8
For j = i + 1 To 8
If chk(i) = chk(j) Then
MessageBox.Show("value enter is repeted !!!" & vbNewLine & "plese check all the numbers......", "check the values", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
Exit Sub
End If
Next
Next
chk1()
End Sub
Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button22.Click
Dim myctrl As Control
For Each myctrl In Panel1.Controls
myctrl.Text = ""
Next
End Sub
Sub chk1()
If Val(Val(Button11.Text) + Val(Button12.Text) + Val(Button13.Text)) = 15 Then
If Val(Val(Button14.Text) + Val(Button15.Text) + Val(Button16.Text)) = 15 Then
If Val(Val(Button17.Text) + Val(Button18.Text) + Val(Button19.Text)) = 15 Then
If Val(Val(Button11.Text) + Val(Button15.Text) + Val(Button19.Text)) = 15 Then
If Val(Val(Button11.Text) + Val(Button14.Text) + Val(Button17.Text)) = 15 Then
If Val(Val(Button12.Text) + Val(Button15.Text) + Val(Button18.Text)) = 15 Then
If Val(Val(Button13.Text) + Val(Button16.Text) + Val(Button19.Text)) = 15 Then
If Val(Val(Button13.Text) + Val(Button15.Text) + Val(Button17.Text)) = 15 Then
MessageBox.Show("matrix is magic matrik", "testing", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
Exit Sub
Else
MessageBox.Show("matrix is not magic matrik", "testing", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
Exit Sub
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button23.Click
Dim frm As Form2
frm = New Form2
frm.Show()
End Sub
End Class