You eaither call that sub from a paint event and pass the e
variable to your sub, or create the Graphics object inside your sub. The Using/End Using blocks dispose of the objects correctly.
Public Sub DrawRectangleInt()
' Create pen.
Using blackPen As New Pen(Color.Black, 3)
' Create location and size of rectangle.
Dim x As Integer = 0
Dim y As Integer = 0
Dim width As Integer = 200
Dim height As Integer = 200
' Draw rectangle to screen.
Using g As Graphics = Me.CreateGraphics
g.DrawRectangle(blackPen, x, y, width, height)
End Using
End Using
End Sub