📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1590
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 1590
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdFib
Caption = "Command1"
Height = 495
Left = 2760
TabIndex = 2
Top = 600
Width = 1095
End
Begin VB.TextBox txtoutput
Height = 375
Left = 600
TabIndex = 1
Top = 840
Width = 1455
End
Begin VB.TextBox txtInput
Height = 375
Left = 600
TabIndex = 0
Top = 240
Width = 1455
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdFib_Click()
Dim intNumber As Integer
intNumber = CInt(txtInput.Text)
If intNumber = 1 Or intNumber = 2 Then ' 如果是第1、2项,直接得出1
txtoutput.Text = 1
Else ' 如果求的是第2项以后的值,使用循环
Dim int1 As Integer, int2 As Integer
Dim intResult As Long
Dim intc As Integer
int1 = 1: int2 = 1
For intc = 3 To intNumber ' For循环
intResult = int1 + int2
int1 = int2 ' 这条语句与下一条语句是否可以交换位置?
int2 = intResult ' 注意如何交换变量的值
Next
txtoutput.Text = intResult ' 输出结果
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -