我重寫了一些代碼,並有一個想法,但似乎無法讓我的語法正確執行它。我想使用for循環來填充一個commandbuttons數組並控制它們的可見性。我只需要我的語法幫助來定義我在循環中處理哪個CommandButton編號。例如,CommandButton1,CommandButton2等。VBA變量作爲CommandButton#
Public Sub LoadLots(sName As String, streamLots() As String)
Label1.Caption = sName
For o = 1 To 9
If streamLots(o) <> "" Then
CommandButton& o &.Caption = streamLots(o)
CommandButton& o & .Visable = True
Else
CommandButton& o & .Visable = False
End If
Next
End Sub
'Activesheet.Shapes( 「命令按鈕」 &O)... .Caption'也'Visable'應該是'Visible' –
我應該補充,這些按鈕在窗體上。 – Flibertyjibbet
原理相同,但下面也有答案。 –