📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "计算圆周率"
ClientHeight = 1620
ClientLeft = 45
ClientTop = 435
ClientWidth = 5220
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1620
ScaleWidth = 5220
StartUpPosition = 1 'CenterOwner
Begin VB.CommandButton Command1
Caption = "计算"
Height = 1095
Left = 4320
TabIndex = 2
Top = 240
Width = 615
End
Begin VB.TextBox Text2
Height = 495
Left = 1200
TabIndex = 1
Top = 840
Width = 2895
End
Begin VB.TextBox Text1
Height = 495
Left = 1200
TabIndex = 0
Top = 240
Width = 2895
End
Begin VB.Label Label2
Caption = "圆周率"
Height = 255
Left = 240
TabIndex = 4
Top = 960
Width = 735
End
Begin VB.Label Label1
Caption = "随机点数"
Height = 255
Left = 240
TabIndex = 3
Top = 360
Width = 735
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
On Error Resume Next
Randomize
Dim n As Long
Dim i As Long
Dim x As Double
Dim y As Double
n = 0
If Val(Text1.Text) < 1 Then Exit Sub
For i = 1 To Val(Text1.Text)
x = Rnd
y = Rnd
If (x * x + y * y <= 1) Then n = n + 1
Next i
Text2.Text = Str(4 * n / Val(Text1.Text))
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -