Hi, guys!

I'm in trouble with it...

I created an array of command buttons (for instance), at runtime, and I need to know which was clicked...

But when I click anyone I have no answer...

What's going on ?

Follows the code where I create the array of command Buttons:

VB Code:
  1. Option Explicit
  2. Dim lbl(4) As Label
  3.  
  4. Private Sub lbl1_Click()
  5.     MsgBox chkbox.Name
  6. End Sub
  7.  
  8.  
  9.  
  10. Private Sub Form_Load()
  11.     Dim x As Byte
  12.  
  13.     For x = 0 To 4
  14.    
  15.     Set lbl(x) = Me.Controls.Add("VB.Label", "lbl" & Me.Controls.Count) '& "(" & x - 1 & ")")
  16.     With lbl(x)
  17.             .Left = 1000
  18.             .Top = 500 * x
  19.             .Width = 2000
  20.             .Height = 500
  21.             .Caption = lbl(x).Name
  22.             .Visible = True
  23.     End With
  24.     Next x
  25. End Sub
  26.    
  27.      
  28.      
  29.     Private Sub Form_Unload(Cancel As Integer)
  30.      
  31.         Dim i As Integer
  32.  
  33.         For i = 0 To 4
  34.             Set lbl(i) = Nothing
  35.         Next i
  36.          
  37.     End Sub

tks!

João Luiz