Ok so i am currently working on a magic square game and basically my form creates an 2d array, dimensions make by user(ex:2 by 2), then the form creates the number of textboxes(Ex:4) and i need to get the values in runtime to check if it is a magic square. Now i know this has something to do with addhandler so ill post my code and any help would be greatly appreciated.
Code:Dim MakeArr(dbltxt - 1, dbltxt - 1) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If dbltxt <= 9 Then Dim introw As Integer = 52 Dim intcol As Integer = 290 For i As Integer = 0 To dbltxt - 1 intcol = 290 introw += 30 For j As Integer = 0 To dbltxt - 1 intcol += 40 MakeArr(i, j) = New TextBox With MakeArr(i, j) .BringToFront() .Name = ("texbox" & i.ToString & j.ToString) .Text = "0" .Left = intcol .Top = introw .Width = 35 .Height = 25 End With Me.Controls.Add(MakeArr(i, j)) Next Next Else MessageBox.Show("Sorry the Max amount of squares is 9") End If End Sub




Reply With Quote