1,451
社区成员
发帖
与我相关
我的任务
分享
Dim Cmd As Control
For Each Cmd In Me
If TypeName(Cmd) = "CommandButton" Then
s1 = Cmd.Name
s = Val(Replace(Cmd.Name, "Command", ""))
If 0 < s And s < 101 Then Cmd.Enabled = False
End If
Next
caption可能不是很好
也可以用名称来控制
这个代码是用属性的名称里面的内容来比较
你按钮的名称还是可以修改成其他的比如关闭 取消之类的,不影响.
Option Explicit
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
Case 1
Case 2
''...
End Select
End Sub
.
Dim Cmd As Control
For Each Cmd In Me
If TypeName(Cmd) = "CommandButton" Then
s = Val(Replace(Cmd.Caption, "Command", ""))
If 0 < s And s < 101 Then Cmd.Enabled = False
End If
Next
这个就把所有caption为command1~100的button设置成灰色了