📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "完数"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.TextBox txtoutput
Height = 495
Left = 2160
TabIndex = 2
Text = "Text1"
Top = 240
Width = 1575
End
Begin VB.ListBox lstoutput
Height = 2040
Left = 120
TabIndex = 1
Top = 240
Width = 1815
End
Begin VB.CommandButton cmdcalc
Caption = "Command1"
Height = 375
Left = 3600
TabIndex = 0
Top = 2640
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCalc_Click()
Dim int1 As Integer, int2 As Integer
Dim intNumber As Integer, intAmount As Integer
intNumber = 0
For int1 = 2 To 999
intAmount = 0
For int2 = 1 To int1 / 2
If int1 Mod int2 = 0 Then ' 如果是因子
intAmount = intAmount + int2 ' 求因子之和
End If
Next
If int1 = intAmount Then ' 如果为完数
intNumber = intNumber + 1 ' 个数加1
lstoutput.AddItem int1 ' 添加到列表框中
End If
Next
txtoutput.Text = intNumber ' 显示完数个数
End Sub
Private Sub cmdoutput_Click()
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -