I have created a very basic program that moves a shape around the screen but when I look in the task manager, the size gets larger and larger even though I am mostly using local procedure variables.
Does anything look funny???
Private xG As Short
Private yG As Short
Private Sub DrawItems()
Dim graphicsG As System.Drawing.Graphics = Me.CreateGraphics()
Dim rectangleG As New System.Drawing.Rectangle(xG, yG, 20, 20)
graphicsG.Clear(Color.LightGray)
graphicsG.DrawEllipse(System.Drawing.Pens.Black, rectangleG)
graphicsG.DrawRectangle(System.Drawing.Pens.Red, rectangleG)
graphicsG.Dispose()
rectangleG = Nothing
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.Down
yG = yG + 10
Case Keys.Up
yG = yG - 10
Case Keys.Right
xG = xG + 10
Case Keys.Left
xG = xG - 10
End Select
Call DrawItems()
End Sub
Does anything look funny???
Private xG As Short
Private yG As Short
Private Sub DrawItems()
Dim graphicsG As System.Drawing.Graphics = Me.CreateGraphics()
Dim rectangleG As New System.Drawing.Rectangle(xG, yG, 20, 20)
graphicsG.Clear(Color.LightGray)
graphicsG.DrawEllipse(System.Drawing.Pens.Black, rectangleG)
graphicsG.DrawRectangle(System.Drawing.Pens.Red, rectangleG)
graphicsG.Dispose()
rectangleG = Nothing
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.Down
yG = yG + 10
Case Keys.Up
yG = yG - 10
Case Keys.Right
xG = xG + 10
Case Keys.Left
xG = xG - 10
End Select
Call DrawItems()
End Sub