Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 控件类型的声明_Excel_Vba - Fatal编程技术网

Excel 控件类型的声明

Excel 控件类型的声明,excel,vba,Excel,Vba,我想知道为什么每次初始化UserForm时,这段代码都会返回一个类型不匹配错误: Private Sub UserForm_Initialize () Dim F as MSForms.Frame For Each F in Me.Controls F.Visible = False Next F End Sub 为了支持我的评论,大概是这样 Dim c As Control For Each c In Me.Controls If Ty

我想知道为什么每次初始化UserForm时,这段代码都会返回一个类型不匹配错误:

Private Sub UserForm_Initialize ()

    Dim F as MSForms.Frame

    For Each F in Me.Controls
        F.Visible = False
    Next F

End Sub

为了支持我的评论,大概是这样

Dim c As Control

For Each c In Me.Controls
    If TypeOf c Is Frame Then
        c.Visible = True
    End If
Next c

为了支持我的评论,大概是这样

Dim c As Control

For Each c In Me.Controls
    If TypeOf c Is Frame Then
        c.Visible = True
    End If
Next c

F
将是循环方式中的控件。您需要将F调暗为控件,然后查看它的类型不是每个控件都是帧
F
将以循环的方式成为控件。你需要调暗F作为控件,然后看看它的类型不是每个控件都是框架谢谢!我只是想避免将F声明为控件,因为我有各种类型的控件,并且不是所有控件都具有相同的属性。谢谢!我只是想避免将F声明为控件,因为我有各种类型的控件,并且不是所有控件都具有相同的属性。