I am using this code to load one object from an array of command buttons:


VB Code:
  1. 'This is a global variable
  2. Dim cmdNew(4) As CommandButton
  3.    
  4.     Set cmdNew(0) = Me.Controls.Add("VB.CommandButton", "cmdButton" & Me.Controls.Count)
  5.    
  6.     With cmdNew(0)
  7.         .Left = 1000
  8.         .Top = 1000
  9.         .Width = 2000
  10.         .Height = 500
  11.         .Caption = "Woof"
  12.         .Visible = True
  13.     End With
  14.    
  15.     Set cmdNew(0) = Me.Controls.Add("VB.CommandButton", "cmdButton" & Me.Controls.Count)




This code will make one commandbutton on the form. But is it also possible to write code for the events for this command button. I tried write this:


VB Code:
  1. Private Sub cmdNew_Click(Index As Integer)
  2.  
  3.     cmdNew(0).Caption = "Nese"
  4.     Command1(1).Caption = "Dust"
  5.    
  6. End Sub


but it doesn't work.


My other question is what is the parameters for the add function I have used. I found the line of code in a book. But it didn't tell me what the parameters what. Anyone know?

My last question is. Is cmdNew here the same or more or less the same as a pointer in C++ or any other language?