📄 计算器.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "计算器"
ClientHeight = 3990
ClientLeft = 60
ClientTop = 450
ClientWidth = 3765
LinkTopic = "Form1"
ScaleHeight = 3990
ScaleWidth = 3765
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Caption = "所有因子"
Height = 375
Left = 2400
TabIndex = 14
Top = 2760
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "开根"
Height = 375
Left = 2400
TabIndex = 13
Top = 2160
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "AC"
Height = 375
Left = 2400
TabIndex = 12
Top = 1560
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "9"
Height = 375
Index = 9
Left = 1560
TabIndex = 11
Top = 1560
Width = 495
End
Begin VB.CommandButton Command1
Caption = "8"
Height = 375
Index = 8
Left = 840
TabIndex = 10
Top = 1560
Width = 495
End
Begin VB.CommandButton Command1
Caption = "7"
Height = 375
Index = 7
Left = 120
TabIndex = 9
Top = 1560
Width = 495
End
Begin VB.CommandButton Command1
Caption = "6"
Height = 375
Index = 6
Left = 120
TabIndex = 8
Top = 2160
Width = 495
End
Begin VB.CommandButton Command1
Caption = "5"
Height = 375
Index = 5
Left = 840
TabIndex = 7
Top = 2160
Width = 495
End
Begin VB.CommandButton Command1
Caption = "4"
Height = 375
Index = 4
Left = 1560
TabIndex = 6
Top = 2160
Width = 495
End
Begin VB.CommandButton Command1
Caption = "3"
Height = 375
Index = 3
Left = 120
TabIndex = 5
Top = 2760
Width = 495
End
Begin VB.CommandButton Command1
Caption = "2"
Height = 375
Index = 2
Left = 840
TabIndex = 4
Top = 2760
Width = 495
End
Begin VB.CommandButton Command1
Caption = "1"
Height = 375
Index = 1
Left = 1560
TabIndex = 3
Top = 2760
Width = 495
End
Begin VB.CommandButton Command1
Caption = "0"
Height = 375
Index = 0
Left = 120
TabIndex = 2
Top = 3360
Width = 1935
End
Begin VB.TextBox Text2
BackColor = &H0000FFFF&
Height = 375
Left = 240
TabIndex = 1
Top = 840
Width = 3255
End
Begin VB.TextBox Text1
BackColor = &H00FF0000&
Height = 375
Left = 240
TabIndex = 0
Top = 120
Width = 3255
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(Index As Integer)
Dim n As Long
n = Val(Text2.Text)
If (n * 10 + Index) < 100000000 Then Text2.Text = Str(n * 10 + Index) '设置n的最大数1亿
End Sub
Private Sub Command2_Click()
Text2.Text = ""
End Sub
Private Sub Command3_Click()
Dim a, x As Double
Dim i As Integer
x = 2 '设置初始推测值为x为2
a = Val(Text2.Text)
For i = 1 To 10000 '重复迭代10000次
x = (x + a / x) / 2
Next i
Text1.Text = Str(x) '输出结果到Text1.text
End Sub
Private Sub Command4_Click()
Dim n, i As Long
Dim s As String
n = Val(Text2.Text)
For i = 1 To n
If n Mod i = 0 Then '求解n的因子
s = s + Str(i) + " " '将结果先存储在S中
End If
Next i
Text1.Text = s '输出结果到Text1.Text
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -