form1.frm
来自「Visual Basic程序设计视频教程」· FRM 代码 · 共 72 行
FRM
72 行
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 975
Left = 960
TabIndex = 0
Top = 960
Width = 2535
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()
Dim num As Integer
Dim indiv As Integer '个位
Dim ten As Integer '十位
Dim hundred As Integer '百位
Dim thousand As Integer '千位
Dim place As Integer '位数
num = Val(InputBox("请输入一个正整数(0~9999)"))
'确定位数
If num > 999 Then
place = 4
ElseIf num > 99 Then
place = 3
ElseIf num > 9 Then
place = 2
Else
place = 1
End If
'确定各位数的数字
thousand = num \ 1000
hundred = (num - thousand * 1000) \ 100 '百位数
ten = (num - thousand * 1000 - hundred * 100) \ 10 '十位数
indiv = num - thousand * 1000 - hundred * 100 - ten * 10
'各位数
'正序、逆序输出各位数
Select Case place
Case 4
Print thousand, hundred, ten, indiv
Print indiv, ten, hundred, thousand
Case 3
Print hundred, ten, indiv
Print indiv, ten, hundred
Case 2
Print ten, indiv
Print indiv, ten
Case 1
Print indiv
Print indiv
End Select
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?