In reply to Rshields' Post #6, the problem you're having is that you are not referencing your button controls as an array. You have an array of buttons, so you must reference them like this.
VB Code:
P11B(0).Enabled = True
The Count, Item, etc. properties you are getting refer to the array, not the individual buttons that are in the array.
This world is not my home. I'm just passing through.
I think the problem is that you are using "Command" instead of "Command1".
Here is my suggestion for you (assuming you don't want to go with my combobox idea).
Start a new project and put a button on the form. Go to the properties for this button and set the Index Property to 0 (zero). Paste in the following code and adapt it for what you want.
VB Code:
Option Explicit
Private Sub Command1_Click(Index As Integer)
SetEnabled False
Select Case Index
Case 0:
'Do processing for first button here
MsgBox "First Button"
Case 1:
'Do processing for second button here
MsgBox "Second Button"
Case 2:
'etc.
MsgBox "Third Button"
Case Else
MsgBox "Unspecified Button"
End Select
SetEnabled True
End Sub
Private Sub Form_Load()
Dim i As Integer
Command1(0).Top = 80
Command1(0).Left = 80
For i = 1 To 7
Load Command1(i)
Command1(i).Top = Command1(i - 1).Top + 600
Command1(i).Left = 80
Command1(i).Visible = True
Next
End Sub
Private Sub SetEnabled(pEnabled)
Dim c As Control
For Each c In Controls
If c.Name = "Command1" Then c.Enabled = pEnabled
Next
End Sub
This world is not my home. I'm just passing through.
Do you have Option Explict on ?
Have you tried running with Full Compile.
If there is only one bit of advice that could be given to those new to VB (and even to some who have been using vb for years), it should be to require declaration of variables.
MS was 'very bad' not to have made that the default.
You can get to this setting via Tools / Options menu
(You may have to go to all your existing Forms, etc and place this at the top 'Option Explicit'. On future projects it will be done for you.)