Results 1 to 3 of 3

Thread: For...Each...Next problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421
    I have a big problem with this statement because I get an error on the "Next" part of it. My code looks like this...

    Public Sub Clear()
    Dim ctlCB As CommandButton
    For Each ctlCB In frmNew.Controls
    ctlCB.Visible = False
    Next ' Error here
    End Sub

    Any help would be appreciated. Thanks.
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Use this:
    Code:
    Private Sub Command2_Click()
        Dim ctl As Control
        For Each ctl In Controls
            If TypeOf ctl Is CommandButton Then
                ctl.Visible = False
            End If
        Next
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421

    Talking

    That works, thanks Lethal.
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width