Hi
How To Make This Faster

Private Sub MonMove()
        For A = 0 To (Cnt - 1)
            MyControlArray(A).Location = New Point(MyControlArray(A).Left _
- 1,MyControlArray(A).Top)
        Next
    End Sub

first i make A Hundred of PictureBox Later
I use Array
How To Make it Faster ,When It Appear More than 20 Box
It Will BeCome Slower And Slower Later It Move Each Box You Can See IT Move Each Box
My COde So Slow
When TimerTick Will Call MonMove
Timer InterVal is 10
Another Class BulletArray.vb
Array Code

Public Class BulletArray
    Inherits System.Collections.CollectionBase
    Private ReadOnly HostForm As System.Windows.Forms.Form
    Public Sub New(ByVal host As System.Windows.Forms.Form)
        HostForm = host
        Me.AddNewBullet()
    End Sub
    Public Function AddNewbullet() As System.Windows.Forms.PictureBox
        Dim aPictureBox As New System.Windows.Forms.PictureBox()
        Me.List.Add(aPictureBox)
        HostForm.Controls.Add(aPictureBox)
        aPictureBox.Top = Count * 25
        aPictureBox.Left = 100
        aPictureBox.Tag = Me.Count
        aPictureBox.BackColor = Color.Black
        aPictureBox.Size = New Size(10, 5)
        AddHandler aPictureBox.Click, AddressOf ClickHandler
        Return aPictureBox
    End Function
    Default Public ReadOnly Property Item(ByVal Index As Integer) As  _
       System.Windows.Forms.PictureBox
        Get
            Return CType(Me.List.Item(Index), System.Windows.Forms.PictureBox)
        End Get
    End Property

    Public Sub Remove()
        If Me.Count > 0 Then
            HostForm.Controls.Remove(Me(Me.Count - 1))
            Me.List.RemoveAt(Me.Count - 1)
        End If
    End Sub
    Public Sub ClickHandler(ByVal sender As Object, ByVal e As  _
   System.EventArgs)
        MessageBox.Show("you have clicked button " & CType(CType(sender,  _
           System.Windows.Forms.PictureBox).Tag, String))
    End Sub

End Class

This Code Change From MSDN ButtonArrayProject
Thanks For Help

Recommended Answers

All 6 Replies

What are you trying to do?

Make It Faster

Yes. I got that.

What is it that you want to go faster??
Do you want something to move?
Do you want to add pictureboxes faster?
What?

I Change The Location Of Each Control
When It HAve More Control It Will Be Slower
It Move Each Control Not All In one Step
I Want To Move in One Step Not Move Each Control
I See How About Multithread

Yes. Well.
Having 100 pictureboxes on the form and moving them at the same time in a timer event, will slow things down.
Based on the name of your class BulletArray I'm gonna assume that the pictureboxes contain a picture of a bullet, and that moving the picturebox somehow will simulate that the bullet is moving.

You should instead look into using GDI, and use the Paint method for a panel to move your bullet.
This is just a sample of what can be done, practically flicker free.
The sample is based on this article.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.