Advertisement
Guest User

Exercise 4

a guest
Jun 13th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.  
  3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.         Me.AutoSize = True : Me.Text = "Graph by 40602154"
  5.         PictureBox1.Top = 0 : PictureBox1.Left = 0
  6.         PictureBox1.Width = 480 : PictureBox1.Height = 280
  7.         Button1.Text = "Draw" : Button1.Font = New Font("Courier", 20)
  8.         Button1.Width = 100 : Button1.Height = 50
  9.         Button1.Top = 10 : Button1.Left = PictureBox1.Width + 50
  10.     End Sub
  11.  
  12.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  13.         Dim myGraph As Graphics = PictureBox1.CreateGraphics
  14.         Dim myPen1, myPen2 As Pen
  15.         Dim mybrush As Brush
  16.         Dim id, a, b, x, y, width As Integer
  17.         myPen1 = New Pen(Color.Red, 5)
  18.         myPen2 = New Pen(Color.Orange, 3)
  19.         mybrush = New SolidBrush(Color.Orange)
  20.         myGraph.DrawRectangle(myPen1, 0, 0, 480, 280)
  21.         b = 20
  22.  
  23.         For id = 1 To 10
  24.             a = 40
  25.             x = (b * id) + 20
  26.             y = b * (id - 1)
  27.             width = 400 - ((id - 1) * a)
  28.  
  29.             myGraph.DrawRectangle(myPen2, x, y, width, b)
  30.             myGraph.FillRectangle(mybrush, x, y, width, b)
  31.         Next
  32.     End Sub
  33. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement