Public Class Form1
    Dim Graph1 As Graphics
    Dim Pen1 As New Pen(Color.Black, 1)
    Dim I, N, M, X, Y, R As Long
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Graph1 = Me.PictureBox1.CreateGraphics()
        'стирание
        Graph1.Clear(Color.White)
        'ввод данных
        N = Val(TextBox1.Text)
        R = Val(TextBox2.Text)
        'Сдвиг по осям x и y
        Graph1.TranslateTransform(100, 100)
        'рисование круга и квадрата
        Graph1.DrawEllipse(Pen1, -R, -R, 2 * R, 2 * R)
        Graph1.DrawRectangle(Pen1, -R, -R, 2 * R, 2 * R)
        For I = 1 To N
            'Генерация случайных координат точек и рисование точек в графическом поле
            X = Int(Rnd() * 2 * R) - R
            Y = Int(Rnd() * 2 * R) - R
            Graph1.DrawEllipse(Pen1, X, Y, 1, 1)
            'ПОДСЧЕТ ТОЧЕК,ПОПАВШИХ ВНУТРЬ КРУГА
            If X ^ 2 + Y ^ 2 <= R ^ 2 Then M = M + 1
        Next I
        'ВЫВОД ПЛОЩАДИ КРУГА И ЧИСЛА Pi
        Label1.Text = 4 * (M / N) * (R ^ 2)
        Label2.Text = 4 * (M / N)



    End Sub

    Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click

    End Sub
End Class
