⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmfibonacci.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmFibonacci 
   Caption         =   "Fig. 6.27: Fibonacci Numbers"
   ClientHeight    =   2130
   ClientLeft      =   2565
   ClientTop       =   2520
   ClientWidth     =   4755
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2130
   ScaleWidth      =   4755
   Begin VB.CommandButton cmdCalculate 
      Caption         =   "Calculate Fibonacci"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1110
      TabIndex        =   1
      Top             =   1440
      Width           =   2535
   End
   Begin VB.TextBox txtInput 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3120
      TabIndex        =   0
      Top             =   120
      Width           =   1215
   End
   Begin VB.Label lblValue 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   3
      Top             =   840
      Width           =   4215
   End
   Begin VB.Label lblInput 
      Caption         =   "Enter an Integer:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   2
      Top             =   120
      Width           =   2055
   End
End
Attribute VB_Name = "frmFibonacci"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 6.27
' Recursively generating Fibonacci numbers
Option Explicit      ' General declaration

Private Sub cmdCalculate_Click()
   Dim fibonacciValue As Variant
      
   lblValue.Caption = ""     ' Clear lblValue Caption
   
   ' Change the mouse pointer to an hourglass shape
   Screen.MousePointer = vbHourglass
   
   fibonacciValue = Fibonacci(txtInput.Text)
   lblValue.Caption = "Fibonacci Value is " & fibonacciValue
   
   ' Change the mouse pointer to the default
   Screen.MousePointer = vbDefault
End Sub

Private Function Fibonacci(n As Variant) As Variant
   
   If (n = 0 Or n = 1) Then
      Fibonacci = n   ' Base Case
   Else
      ' Recursive step
      Fibonacci = Fibonacci(n - 1) + Fibonacci(n - 2)
   End If

End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -