Public Class Form1 Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click Dim paper As Graphics paper = PictureBox1.CreateGraphics() paper.Clear(Color.Gold) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim paper, paper1 As Graphics Dim mypen As Pen paper = PictureBox1.CreateGraphics() mypen = New Pen(Color.Blue, 3) paper1 = PictureBox2.CreateGraphics() DrawLogo(paper, mypen, 5, 5, 50, 50) mypen = New Pen(Color.Red, 8) DrawLogo(paper, mypen, 300, 50, 70, 70) mypen = New Pen(Color.Green, 1) DrawLogo(paper, mypen, 5, 200, 30, 30) mypen = New Pen(Color.White, 5) DrawTriangle(paper1, mypen, 10, 10, 100, 160) MessageBox.Show(CStr(TriangleArea(100, 160))) End Sub Private Function TriangleArea(ByVal width As Integer, ByVal height As Integer) As Double Dim area As Double area = width * height / 2 Return (area) End Function Private Sub DrawLogo(ByVal drawingArea As Graphics, _ ByVal pen As Pen, _ ByVal x As Integer, _ ByVal y As Integer, _ ByVal width As Integer, _ ByVal height As Integer) drawingArea.DrawRectangle(Pen, x, y, width, height) drawingArea.DrawRectangle(Pen, x, y, 2 * width, 2 * height) drawingArea.DrawRectangle(Pen, x, y, 3 * width, 3 * height) End Sub Private Sub DrawTriangle(ByVal drawingArea As Graphics, _ ByVal pen As Pen, _ ByVal x As Integer, _ ByVal y As Integer, _ ByVal width As Integer, _ ByVal height As Integer) drawingArea.DrawLine(pen, x, y, x, y + height) drawingArea.DrawLine(pen, x, y, x + width, y + height) drawingArea.DrawLine(pen, x, y + height, x + width, y + height) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click Dim x As Graphics x = PictureBox2.CreateGraphics() x.Clear(Color.Aquamarine) End Sub End Class