I have a user control which is supposed to act sort of like the Windows Taskbar. I have added a function to add and delete buttons (from an array) but I CAN'T GET THE F***ING THINK TO WORK.
That's how it adds the button. I call it from another form like so:Code:Public Function AddButton(Optional strCaption As String) Dim X As Long X = cmdButton.Count + 1 Load cmdButton(X) 'Create instance (for instance, this button) cmdButton(X).Left = 60 + X * (cmdButton(0).Width + 60) cmdButton(X).Top = 60 cmdButton(X).Caption = strCaption cmdButton(X).Width = cmdButton(0).Width 'Index 0 is main Button cmdButton(X).Height = cmdButton(0).Height cmdButton(X).Visible = True End Function
But instead of showing a new button, it just adds another one to the array, whereas if I did this:Code:Private Sub Command1_Click() UserControl1.AddButton "Hello" MsgBox UserControl1.ButtonCount 'Property I added to see if the button was actually added to an array End Sub
It works.Code:Private Sub Command1_Click(Index As Integer) 'Creating instance of self 'Coordinates of main button: (0,0) Load Command1(2) Command1(2).Move 50, 50 End Sub
So, does anyone know why these buttons aren't showing up? Believe you me, I've tried everything, and yet the answer is probably so simple!


Reply With Quote

