Private Sub Command1_Click()
Dim n As Long, k As Integer
Dim f1 As Long, f2 As Long, f As Long
=Val(Text1.Text)
If n >= 20 Or n <= 0 Then
Label2.Caption = "输入的数据有误"
Else
If n <= 2 Then ' 第1,2个元素的值都为1
f = 1
Else
f1 = 1
f2 = 1
For k = 3 To n
f = f1 + f2
f1 = f2
f2 = f
Nextk
End If
Label2.Caption = "斐波那契数列第" + Str(n) + "项的值为" +
End If
End Sub