Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27351

How Can I Move Rectangles in Picturebox ?

$
0
0
I draw 2 rectangles in picturebox and I need to move them with a Timer.
I wrote this but it didn't work.


Code:

Public Class Form1
    Dim kalem As New Drawing.Pen(Color.Black)
    Dim solx1 As Integer, soly1 As Integer, solen As Integer, solboy As Integer
    Dim sagx1 As Integer, sagy1 As Integer, sagen As Integer, sagboy As Integer
   

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Start()
    End Sub

    Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint

        solx1 = 5
        soly1 = 5
        solen = 10
        solboy = 15
        sagx1 = 20
        sagy1 = 5
        sagen = 10
        sagboy = 15

        Dim teker As Rectangle() = {New Rectangle(solx1, soly1, solen, solboy), _
                                  New Rectangle(sagx1, sagy1, sagen, sagboy)}

        e.Graphics.DrawRectangles(kalem, teker)

    End Sub

 
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        solx1 = solx1 + 5
        sagx1 = sagx1 + 5

    End Sub
End Class


Viewing all articles
Browse latest Browse all 27351

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>