form1.frm
来自「Visual Basic程序设计视频教程」· FRM 代码 · 共 48 行
FRM
48 行
VERSION 5.00
Begin VB.Form Form1
Caption = "水仙花数"
ClientHeight = 2565
ClientLeft = 60
ClientTop = 360
ClientWidth = 3405
LinkTopic = "Form1"
ScaleHeight = 2565
ScaleWidth = 3405
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "显示所有水仙花数"
Height = 495
Left = 120
TabIndex = 0
Top = 1920
Width = 1695
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()
'i,j,k分别代表百位,十位和个位
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim n As Integer
Form1.Cls
Print "水仙花数为:"
For n = 100 To 999 Step 1
'求百位十位和个位
i = n \ 100
j = (n - i * 100) \ 10
k = n Mod 10
'如果是水仙花数则打印
If (n = i ^ 3 + j ^ 3 + k ^ 3) Then
Print n
End If
Next n
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?