Sub LoadBoth(ByVal R1C0 As Integer) Dim newbox As TextBox, ThisIndex As Integer Panel1.Controls.Clear() itswidth = Val(Textwidth.Text) ItsHeigt = Val(TextHeigt.Text) gapLeft = Val(TextLeftGap.Text) GapTop = Val(TextTopGap.Text) GapCol = Val(TextGapX.Text) GapRow = Val(TextGapY.Text) NumCols = Val(TextCols.Text) NumRows = Val(TextRow.Text) ' BTRVER() As Button, BTNHOR() As Button BTNAll = New Button BTNAll.Location = New Point(13, 119) BTNAll.Size = New Drawing.Size(itswidth * 2, ItsHeigt * 2) AddHandler BTNAll.MouseMove, AddressOf AllSumHere AddHandler BTNAll.Click, AddressOf AllSumHere BTNAll.Text = "SUM" BTNAll.Visible = True BTNAll.BackColor = Color.Brown Me.Controls.Add(BTNAll) ReDim BTRVER(NumRows) Panelver.Controls.Clear() Dim newBTN As Button Dim VarRow As Integer = 0 For VarRows = 1 To NumRows newBTN = New Button newBTN.Size = New Drawing.Size(itswidth, ItsHeigt) newBTN.Location = New Point(gapLeft, GapTop + (ItsHeigt + GapRow) * (VarRows - 1)) newBTN.Name = "B" & VarRows newBTN.Text = VarRows ' newbox.Name AddHandler newBTN.MouseMove, AddressOf BTNRowCLICK '2 AddHandler newBTN.Click, AddressOf BTNRowCLICK '2 BTRVER(VarRows) = newBTN Panelver.Controls.Add(newBTN) Next Panelver.Height = (GapRow + ItsHeigt) * Val(TextRow.Text) + 10 '''''''''''''''''''''''''''''' Dim VarCol As Integer Dim newHor As Button ReDim BTNHOR(NumCols) Panelhori.Controls.Clear() For VarCol = 1 To NumCols newHor = New Button newHor.Size = New Drawing.Size(itswidth, ItsHeigt) newHor.Location = New Point(gapLeft + (itswidth + Val(TextGapX.Text)) * (VarCol - 1), GapTop) newHor.Name = "B" & VarCol newHor.Text = VarCol ' newbox.Name AddHandler newHor.MouseHover, AddressOf BTNColCLICK '2 AddHandler newHor.Click, AddressOf BTNColCLICK '1 BTNHOR(VarCol) = newHor Panelhori.Controls.Add(newHor) Next Panelhori.Width = (GapCol + itswidth) * Val(TextCols.Text) + 10 ''''''''''''''''''''''''''''''' ReDim runtext(NumRows * NumCols) For VarRows As Integer = 1 To NumRows For VarCol = 1 To NumCols newbox = New TextBox newbox.Size = New Drawing.Size(itswidth, ItsHeigt) If R1C0 = 1 Then ThisIndex = (VarCol - 1) * NumRows + VarRows ' For VarRows ElseIf R1C0 = 0 Then ThisIndex = (VarRows - 1) * NumCols + VarCol 'For VarCol End If newbox.Location = New Point(gapLeft + (itswidth + Val(TextGapX.Text)) * (VarCol - 1), GapTop + (ItsHeigt + GapRow) * (VarRows - 1)) newbox.Name = "T" & ThisIndex 'VarRows & "_" & VarCol newbox.Text = ThisIndex ' newbox.Name AddHandler newbox.TextChanged, AddressOf TextBox_TextChanged runtext(ThisIndex) = newbox runtext(ThisIndex).Multiline = True Panel1.Controls.Add(newbox) Next Next Panel1.Width = (GapCol + itswidth) * Val(TextCols.Text) + 10 Panel1.Height = (GapRow + ItsHeigt) * Val(TextRow.Text) + 10 Me.Height = Panel1.Height + Panel1.Top + 100 Me.Width = Panel1.Width + Panel1.Left + 100 'Me.AutoScroll = True Me.Location = New Point(10, 10) End Sub