Office中国论坛/Access中国论坛

标题: VBA编程的十万个优良习惯(5) 免费测试中 [打印本页]

作者: 大熊    时间: 2003-4-3 19:04
标题: VBA编程的十万个优良习惯(5) 免费测试中
请试改进和规范下面例程。
Sub FlipEnable(pctl As control, pfrm As Form, pstrScope As String)
Dim ctlEach As control
    For Each ctlEach In pfrm.Controls
        If TypeName(ctlEach) = TypeName(pctl) Then '是否同一类
            If pstrScope = "All" Then
                ctlEach.Enabled = Not ctlEach.Enabled
                If TypeName(ctlEach) <> "CommandButton" Then
                    ctlEach.Locked = Not ctlEach.Locked
                End If
            ElseIf pstrScope = "Except" Then
                If ctlEach.name <> pctl.name Then '是否为参数对象
                    ctlEach.Enabled = Not ctlEach.Enabled
                    If TypeName(ctlEach) <> "CommandButton" Then
                        ctlEach.Locked = Not ctlEach.Locked
                    End If
                End If
            End If
        End If
    Next
End Sub
http://www.officefans.net/cdb/viewthread.php?tid=7976&page=1&sid=bca4e046269849253c60f150ab100f3d#pid19110


[此贴子已经被作者于2003-4-3 16:21:17编辑过]


作者: tmtony    时间: 2003-4-5 08:58
不错:)




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3