Advertisement
Guest User

drw line 5

a guest
Jun 15th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.79 KB | None | 0 0
  1. Public Class Form1
  2.  
  3.  
  4.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  5.         Me.AutoSize = True : Me.Text = "Graph by 40602146"
  6.         PictureBox1.Top = 0 : PictureBox1.Left = 0
  7.         PictureBox1.Width = 505 : PictureBox1.Height = 505
  8.         Button1.Text = "Draw" : Button1.Font = New Font("Courier", 20)
  9.         Button1.Width = 100 : Button1.Height = 50
  10.         Button1.Top = 10 : Button1.Left = PictureBox1.Width + 50
  11.  
  12.     End Sub
  13.  
  14.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  15.         Dim myGraphics As Graphics = PictureBox1.CreateGraphics
  16.         Dim myPen1, myPen2 As Pen
  17.         Dim id, x, y, w, h As Integer
  18.         myPen1 = New Pen(Color.Blue, 5)
  19.         myPen2 = New Pen(Color.Gray, 50)
  20.         myGraphics.DrawRectangle(myPen1, 0, 0, 505, 505)
  21.         For id = 1 To 5
  22.             x = (id - 1) * 100 + 2.5 : y = 25 + 2.5 : w = 50 + ((id - 1) * 100) + 2.5 : h = y
  23.             myGraphics.DrawLine(myPen2, x, y, w, h)
  24.             myGraphics.DrawLine(myPen2, x, y + 100, w, h + 100)
  25.             myGraphics.DrawLine(myPen2, x, y + 200, w, h + 200)
  26.             myGraphics.DrawLine(myPen2, x, y + 300, w, h + 300)
  27.             myGraphics.DrawLine(myPen2, x, y + 400, w, h + 400)
  28.         Next
  29.  
  30.         For id = 1 To 5
  31.             x = 50 + ((id - 1) * 100) + 2.5 : y = 75 + 2.5 : w = 100 + ((id - 1) * 100) + 2.5 : h = y
  32.             myGraphics.DrawLine(myPen2, x, y, w, h)
  33.             myGraphics.DrawLine(myPen2, x, y + 100, w, h + 100)
  34.             myGraphics.DrawLine(myPen2, x, y + 200, w, h + 200)
  35.             myGraphics.DrawLine(myPen2, x, y + 300, w, h + 300)
  36.             myGraphics.DrawLine(myPen2, x, y + 400, w, h + 400)
  37.      
  38.         Next
  39.     End Sub
  40. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement