Государственная аттестация по дисциплинам программистского цикла. Курганский В.И - 14 стр.

UptoLike

14
End Sub
Private Sub Command4_Click() ' Вычисление длины ломаной
Dim l
l = 0
For i = 2 To UBound(Points)
p1.X = Points(i - 1).X
p1.Y = Points(i - 1).Y
p.X = Points(i).X
p.Y = Points(i).Y
l = l + Sqr((p1.X - p.X) ^ 2 + (p1.Y - p.Y) ^ 2)
Next
Label8.Caption = CStr(Round(l, 2))
End Sub
Private Sub Command6_Click() ‘ Сброс ломаной и результатов
Call Form_Load
End Sub
Private Sub Form_Load() ‘ Начальные установки
ReDim Points(0)
Tek = 0
Label1.Caption = ""
Label2.Caption = ""
Picture1.Cls
Label8.Caption = ""
Me.Width = Picture1.Left + Picture1.Width + 500
Me.Height = Picture1.Top + Picture1.Height + 1000
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Label1.Caption = Str(X)
Label1.Refresh
Label2.Caption = Str(Y)
Label2.Refresh
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
' Рисование точки
Picture1.Circle (X, Y), 2, vbRed
p.X = X
p.Y = Y
' Пополнение массива точек
End Sub

Private Sub Command4_Click() ' Вычисление длины ломаной
  Dim l
  l=0
  For i = 2 To UBound(Points)
    p1.X = Points(i - 1).X
    p1.Y = Points(i - 1).Y
    p.X = Points(i).X
    p.Y = Points(i).Y
    l = l + Sqr((p1.X - p.X) ^ 2 + (p1.Y - p.Y) ^ 2)
  Next
  Label8.Caption = CStr(Round(l, 2))
End Sub

Private Sub Command6_Click() ‘ Сброс ломаной и результатов
  Call Form_Load
End Sub

Private Sub Form_Load() ‘ Начальные установки
  ReDim Points(0)
  Tek = 0
  Label1.Caption = ""
  Label2.Caption = ""
  Picture1.Cls
  Label8.Caption = ""
  Me.Width = Picture1.Left + Picture1.Width + 500
  Me.Height = Picture1.Top + Picture1.Height + 1000
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
  Label1.Caption = Str(X)
  Label1.Refresh
  Label2.Caption = Str(Y)
  Label2.Refresh
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
  ' Рисование точки
  Picture1.Circle (X, Y), 2, vbRed
  p.X = X
  p.Y = Y
  ' Пополнение массива точек
14