Bagosep

Create dot and line manual with VB

Oct 1st, 2017
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub Blue_Click(Index As Integer)
  2. Form1.ForeColor = vbBlue
  3. End Sub
  4. Private Sub full_Click()
  5. Form1.WindowState = FormWindowState.Maximized
  6. End Sub
  7.  
  8. Private Sub Default_Click(Index As Integer)
  9. Form1.ForeColor = vbBlack
  10. End Sub
  11.  
  12. Private Sub opsiGreen_Click(Index As Integer)
  13. Form1.ForeColor = vbGreen
  14. End Sub
  15. Private Sub opsiRed_Click(Index As Integer)
  16. Form1.ForeColor = vbRed
  17. End Sub
  18. Sub garis(x1, y1, x2, y2)
  19. dx = x2 - x1
  20. dy = y2 - y1
  21.  
  22. If x2 < x1 And y2 < y1 Then
  23.     dx = x1 - x2
  24.     dy = y1 - y2
  25. End If
  26.  
  27. If x2 < x1 And y2 = y1 Then
  28.     dx = x1 - x2
  29. End If
  30.  
  31. If y2 < y1 And x2 = x1 Then
  32.     dy = y1 - y2
  33. End If
  34.  
  35. If dx > dy Then
  36.     l = dx
  37. Else
  38.     l = dy
  39. End If
  40.  
  41. If x2 < x1 And y1 = y2 Then
  42.     dx = dx - 2 * dx
  43. End If
  44.  
  45. If y2 < y1 And x1 = x2 Then
  46.     dy = dy - 2 * dy
  47. End If
  48.  
  49.  
  50. If dx = 0 Then
  51.     incx = 0
  52. Else
  53.     incx = dx / l
  54. End If
  55.  
  56. If dy = 0 Then
  57.     incy = 0
  58. Else
  59.     incy = dy / l
  60. End If
  61.  
  62. x = x1
  63. y = y1
  64.  
  65.  
  66. If x2 < x1 And y2 < y1 Then
  67. x = x2
  68. y = y2
  69. End If
  70.  
  71.  
  72. For i = 1 To l
  73. Form1.PSet (x, y)
  74. x = x + incx
  75. y = y + incy
  76. Next i
  77. End Sub
  78. Private Sub sumbuX_KeyPress(KeyAscii As Integer)
  79.  If KeyAscii = 13 Then
  80.         Form1.Cls
  81.         Form1.PSet (sumbuX, sumbuY)
  82.        
  83.         Form1.PSet (sumbuX, sumbuY + 2)
  84.         Form1.PSet (sumbuX, sumbuY - 2)
  85.         Form1.PSet (sumbuX - 2, sumbuY)
  86.         Form1.PSet (sumbuX + 2, sumbuY)
  87.     End If
  88. End Sub
  89. Private Sub sumbuX1_KeyPress(KeyAscii As Integer)
  90. If KeyAscii = 13 Then
  91.     x1 = Int(sumbuX1.Text)
  92.     y1 = Int(sumbuY1.Text)
  93.     x2 = Int(sumbuX2.Text)
  94.     y2 = Int(sumbuY2.Text)
  95.     Form1.Cls
  96.     Call garis(x1, y1, x2, y2)
  97. End If
  98. End Sub
  99. Private Sub sumbuX2_KeyPress(KeyAscii As Integer)
  100. If KeyAscii = 13 Then
  101.     x1 = Int(sumbuX1.Text)
  102.     y1 = Int(sumbuY1.Text)
  103.     x2 = Int(sumbuX2.Text)
  104.     y2 = Int(sumbuY2.Text)
  105.     Form1.Cls
  106.     Call garis(x1, y1, x2, y2)
  107. End If
  108. End Sub
  109.  
  110. Private Sub sumbuY_KeyPress(KeyAscii As Integer)
  111.     If KeyAscii = 13 Then
  112.         Form1.Cls
  113.         Form1.PSet (sumbuX, sumbuY)
  114.         Form1.PSet (sumbuX, sumbuY + 2)
  115.         Form1.PSet (sumbuX, sumbuY - 2)
  116.         Form1.PSet (sumbuX - 2, sumbuY)
  117.         Form1.PSet (sumbuX + 2, sumbuY)
  118.     End If
  119. End Sub
  120. Private Sub sumbuY1_KeyPress(KeyAscii As Integer)
  121. If KeyAscii = 13 Then
  122.     x1 = Int(sumbuX1.Text)
  123.     y1 = Int(sumbuY1.Text)
  124.     x2 = Int(sumbuX2.Text)
  125.     y2 = Int(sumbuY2.Text)
  126.     Form1.Cls
  127.     Call garis(x1, y1, x2, y2)
  128. End If
  129. End Sub
  130. Private Sub sumbuY2_KeyPress(KeyAscii As Integer)
  131. If KeyAscii = 13 Then
  132.     x1 = Int(sumbuX1.Text)
  133.     y1 = Int(sumbuY1.Text)
  134.     x2 = Int(sumbuX2.Text)
  135.     y2 = Int(sumbuY2.Text)
  136.     Form1.Cls
  137.     Call garis(x1, y1, x2, y2)
  138. End If
  139. End Sub
RAW Paste Data