user12780118
user12780118

Reputation: 15

Declaration of control type

I wonder why this piece of code returns a type mismatch error whenever the UserForm is initialized:

Private Sub UserForm_Initialize ()

    Dim F as MSForms.Frame

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

End Sub

Upvotes: 1

Views: 71

Answers (1)

Nathan_Sav
Nathan_Sav

Reputation: 8531

In support of my comment, something like so

Dim c As Control

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

Upvotes: 3

Related Questions