See if this helps.
Public Class Form1
Private cls As New myCoolClass '// get access to your Class.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cls.myTimer.Enabled = Not cls.myTimer.Enabled '// toggle timer on/off.
End Sub
End Class
Public Class myCoolClass
'// WithEvents, to get the Events in the right ComboBox, when selecting your object in the left ComboBox of the code window.
Public WithEvents myTimer As New Timer With {.Interval = 1000} '// 1000 is 1 second.
'// found in the right ComboBox of top of code window.
Private Sub myTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles myTimer.Tick
drawCoolShape(Form1) '// Call the drawCoolShape Sub.
End Sub
'// Draw Shape.
Private Sub drawCoolShape(ByVal selectedForm As Form)
Static bToggleColor As Boolean = True '// Toggles the colors of the pen the shape is drawn with.
Dim myGraphics As Graphics = selectedForm.CreateGraphics
Dim myPen As Pen '// pen to draw with.
'// set pen color and width.
If bToggleColor = True Then myPen = New Pen(Color.SteelBlue, 10) Else myPen = New Pen(Color.Orange, 10)
myGraphics.DrawEllipse(myPen, 50, 50, 10, 10) '// (preset pen, location.X, location.Y, width, height)
bToggleColor = Not bToggleColor '// Toggle the Boolean True/False.
End Sub
End Class I added the Class on the same code page as Form1.
You can also add a Class as a separate Item and use the posted code in the same way.