Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete ll picturebox in a form

sal21

Programmer
Apr 26, 2004
494
IT
how to delete all picturrebox in a form with the name PIC1, PIC2, PIC3, PICnn

note:
the pictureboxes are over an image controll
 
Continuing with your poorly though out solution, eh?

Well, hers example code for doing precisely what you have asked for (plus some minor alternatives)


Rich (BB code):
Private Sub Command1_Click()
    Dim picbox
    Set picbox = Me.Controls.Add("VB.PictureBox", "PIC1")
    picbox.Move 0, 0, 100, 100
    picbox.Visible = True
End Sub

Private Sub Command2_Click()
    Dim myitem As Control
    For Each myitem In Me.Controls
        If TypeOf myitem Is PictureBox Then
            If Left(myitem.Name, 3) = "PIC" Then Me.Controls.Remove (myitem.Name)
        End If
    Next
End Sub

Private Sub Command3_Click()
    Dim myitem As Control
    For Each myitem In Me.Controls
        If TypeOf myitem Is PictureBox Then
             If Left(myitem.Name, 3) = "PIC" Then myitem.Visible = False
        End If
    Next
End Sub
Private Sub Command4_Click()
    Dim myitem As Control
    For Each myitem In Me.Controls
        If TypeOf myitem Is PictureBox Then
            If Left(myitem.Name, 3) = "PIC" Then myitem.Move -5000, -5000
        End If
    Next
End Sub
 

Part and Inventory Search

Sponsor

Back
Top