My Code ... its not looping right

vbMarkO

Centurion
Joined
Aug 19, 2005
Messages
157
This I think should loop through placing a picbox at each location

But it only places the first one but when I debug it it appeas as though its looping through and I see the coorinates ... I'm just not seeing it happen on my app
here is the code

Code:
 Dim PB As New PictureBox
        Dim myAdds() As String = {"8100 S Riverside", "7100 S Riverside"}
        Dim myECoord() As Integer = {400, 275}
        Dim mySCoord() As Integer = {916, 708}
        ' ToolTip1.SetToolTip(PB, "81st & Riverside Pkwy")


        For i = 0 To mySCoord.Count - 1
            'Dim myInt1 As Integer = myCoord(0)
            ' Dim myInt2 As Integer = myCoord(1)

            With PB
                .Location = New System.Drawing.Point(myECoord(i), mySCoord(i))
                .Size = New Size(5, 5)
                .BackColor = Color.Red
                .BringToFront()



            End With

            Me.PictureBox1.Controls.Add(PB)

            AddHandler PB.Click, AddressOf MyPicClicked

        Next


Any thoughts Help much appreciated

vbMarkO
 
You're not creating a new instance of a PictureBox each time through the loop. You're reusing the existing one you defined at the top of your code. Move the Dim PB As New PictureBox to inside the loop.
 
Your right .... man ... it was right in front of m and I just knew I was over looking something simple Arrrgh OK then this is solved as that did the trick thanx a bunch


Resolved
 
Back
Top