Hola Atella....
El problema es que lo que estás asignando a una matrix y los eventos en tiempo de ejecución no puede ser una matrix, yo lo haría de la siguiente manera
Agregaría un modulo de Clase al proyecto con el Nombre de Tx por ejemplo (después lo ajustas a tu manera si) en él cargaría el siguiente código:
Option Explicit
Private WithEvents evtText As TextBox
Private xName As String
Private Sub Class_Initialize()
End Sub
Private Sub Class_Terminate()
On Error Resume Next
Set evtText = Nothing
End Sub
Private Sub evtText_Change()
MsgBox "hola - " & xName
‘Controlaría en forma centralizada lo que necesito
End Sub
Public Function TxAdd(ByVal frm As Form, ByVal Name As String, ByVal top As Long, ByVal Lft As Long) As TextBox
On Error Resume Next
Dim tx As TextBox
Set tx = frm.Controls.Add("VB.TextBox", Name)
tx.Visible = True
tx.top = top * 800
tx.Left = Lft * 1600
xName = Name
Set evtText = tx
Set TxAdd = tx
End Function
Ahora en un formulario colocaría lo siguiente:
Option Explicit
Private cc(2, 2) As Object
Private Sub Form_Load()
Dim jk As Integer
Dim jm As Integer
Dim nm As String
For jk = 1 To 2
For jm = 1 To 2
Set cc(jk, jm) = New tx
nm = "tx" & jk & jm
cc(jk, jm).TxAdd Me, nm, jm, jk
Next jm
Next jk
End Sub
Por supuesto trata de ajustarlo a lo tuyo
Espero que te sirva |