VERSION 5.00
Begin VB.Form frm1 
   BackColor       =   &H00004080&
   Caption         =   "Метод Монте-Карло"
   ClientHeight    =   2988
   ClientLeft      =   3984
   ClientTop       =   2988
   ClientWidth     =   4092
   LinkTopic       =   "Form1"
   ScaleHeight     =   2988
   ScaleWidth      =   4092
   Begin VB.TextBox txtR 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   3000
      TabIndex        =   7
      Top             =   240
      Width           =   972
   End
   Begin VB.TextBox txtS 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   3000
      TabIndex        =   3
      Top             =   1320
      Width           =   972
   End
   Begin VB.TextBox txtN 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   3000
      TabIndex        =   2
      Top             =   720
      Width           =   972
   End
   Begin VB.CommandButton cmd1 
      Caption         =   "Пуск"
      Height          =   372
      Left            =   600
      TabIndex        =   1
      Top             =   2520
      Width           =   1332
   End
   Begin VB.PictureBox pic1 
      BackColor       =   &H00FFFFFF&
      Height          =   2052
      Left            =   240
      ScaleHeight     =   2004
      ScaleWidth      =   2004
      TabIndex        =   0
      Top             =   240
      Width           =   2052
   End
   Begin VB.Label lblR 
      Alignment       =   2  'Center
      BackColor       =   &H00FFFFFF&
      Caption         =   "r"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   2520
      TabIndex        =   6
      Top             =   240
      Width           =   372
   End
   Begin VB.Label lblS 
      Alignment       =   2  'Center
      BackColor       =   &H00FFFFFF&
      Caption         =   "S"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   2520
      TabIndex        =   5
      Top             =   1320
      Width           =   372
   End
   Begin VB.Label lblN 
      Alignment       =   2  'Center
      BackColor       =   &H00FFFFFF&
      Caption         =   "N"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   372
      Left            =   2520
      TabIndex        =   4
      Top             =   720
      Width           =   372
   End
End
Attribute VB_Name = "frm1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim dblX, dblY As Double, I, N, M, R As Long, S As Double
Private Sub cmd1_Click()
M = 0
pic1.Cls
R = Val(txtR)
N = Val(txtN)
pic1.Scale (-(R + 1), R + 1)-(R + 1, -(R + 1))
pic1.Line (-R, R)-(R, -R), , B
pic1.Circle (0, 0), R
'Генерация точек
For I = 1 To N
dblX = 2 * R * Rnd - R
dblY = 2 * R * Rnd - R
pic1.PSet (dblX, dblY)
If dblX ^ 2 + dblY ^ 2 <= R Then M = M + 1
Next I
txtS.Text = 4 * R ^ 2 * (M / N)
'Ось X
pic1.Line (-(R + 1), 0)-(R + 1, 0)
For I = -(R + 1) To R + 1
pic1.PSet (I, 0)
pic1.Print I
Next I
'Ось Y
pic1.Line (0, -(R + 1))-(0, R + 1)
For I = -(R + 1) To R + 1
pic1.PSet (0, I)
pic1.Print I
Next I
End Sub

