I am using this code to load one object from an array of command buttons:
VB Code:
'This is a global variable Dim cmdNew(4) As CommandButton Set cmdNew(0) = Me.Controls.Add("VB.CommandButton", "cmdButton" & Me.Controls.Count) With cmdNew(0) .Left = 1000 .Top = 1000 .Width = 2000 .Height = 500 .Caption = "Woof" .Visible = True End With 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:
Private Sub cmdNew_Click(Index As Integer) cmdNew(0).Caption = "Nese" Command1(1).Caption = "Dust" 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?




Reply With Quote