03-09-19, 02:00 AM
كود :
Option Explicit
Const ArrX = 3
Const ArrY = 3
Dim myTextBox(ArrX, ArrY) As TextBox
Private Sub Form_Load()
Dim y As Integer: For y = 0 To ArrY - 1
Dim x As Integer: For x = 0 To ArrX - 1
Dim name: name = "myText" & (y * ArrY + x + 1)
Set myTextBox(x, y) = Controls.Add("VB.TextBox", name, Me)
With myTextBox(x, y)
.Left = T2P(10 + (95 * x))
.Top = T2P(10 + (23 * y))
.Width = T2P(90)
.Height = T2P(20)
.Text = "myTextBox(" & x & ", " & y & ")"
.Visible = True
End With
Next x
Next y
End Sub
Public Function T2P(t) As Integer: T2P = t * Screen.TwipsPerPixelX: End Function
'Private Sub Command1_Click()
' MsgBox myTextBox(1, 1).Text
'End Sub