vbscript 将UserFormControls跨页/标签链接到各自的组

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 将UserFormControls跨页/标签链接到各自的组相关的知识,希望对你有一定的参考价值。

Public ufEventsDisabled As Boolean 
Dim CPOptionButtons As Collection 
 
Private Sub UserForm_Initialize() 
    Dim oneControl As Object 
    Dim oneCPOptionButton As clsCrossParentOptionButton 
     
    Set CPOptionButtons = New Collection 
     
    For Each oneControl In Me.Controls 
        If TypeName(oneControl) = "OptionButton" Then 
            Set oneCPOptionButton = New clsCrossParentOptionButton 
            Set oneCPOptionButton.CPOptionButton = oneControl 
            CPOptionButtons.Add oneCPOptionButton, Key:=oneControl.Name 
        End If 
    Next oneControl 
     
    Set oneCPOptionButton = Nothing 
End Sub 
 
Private Sub UserForm_Terminate() 
    Dim oneCPOptionButton As clsCrossParentOptionButton 
     
    For Each oneCPOptionButton In CPOptionButtons 
        Set oneCPOptionButton = Nothing 
    Next oneCPOptionButton 
     
    Set CPOptionButtons = Nothing 
End Sub 
'Create this class first

Public WithEvents CPOptionButton As MSForms.OptionButton

 
Private Sub cpOptionButton_Change()
    Dim myUF As Object
    Dim oneControl As MSForms.Control
     
    Set myUF = Me.ParentUF
    If myUF.ufEventsDisabled Then Exit Sub
     
    myUF.ufEventsDisabled = True
     
     
    For Each oneControl In myUF.Controls
        With oneControl
            If TypeName(oneControl) = "OptionButton" Then
                If oneControl.GroupName = CPOptionButton.GroupName Then
                    .Value = (.Value And (.Parent.Name = CPOptionButton.Parent.Name))
                End If
            End If
        End With
    Next oneControl
     
    myUF.ufEventsDisabled = False
End Sub
 
Property Get ParentUF() As Object
    Set ParentUF = CPOptionButton.Parent
    On Error Resume Next
    Do
        Set ParentUF = ParentUF.Parent
    Loop Until Err
    On Error GoTo 0
End Property

以上是关于vbscript 将UserFormControls跨页/标签链接到各自的组的主要内容,如果未能解决你的问题,请参考以下文章

VBScript:将具有空值的参数传递给存储过程?

使用 VBScript 将代码回显到文件中

使用 VBScript 访问将备注字段从“纯文本”更改为“富文本”

是否可以将 .ico 文件存储在 vbscript 中?

vbscript将word doc转换为pdf

如何将值从Visual Basic 6程序传递给VBscript代码?