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

📄 frmscope.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmScope 
   Caption         =   "Fig. 6.15: Scoping Example"
   ClientHeight    =   6375
   ClientLeft      =   2010
   ClientTop       =   345
   ClientWidth     =   6450
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   12
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000008&
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   6375
   ScaleWidth      =   6450
   Begin VB.CommandButton cmdGo 
      BackColor       =   &H80000005&
      Caption         =   "Go"
      Height          =   735
      Left            =   4800
      TabIndex        =   0
      Top             =   2820
      Width           =   1455
   End
End
Attribute VB_Name = "frmScope"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 6.15
' Scoping example
Option Explicit     ' General declaration
Dim x As Integer    ' Module variable in general declaration

Private Sub cmdGo_Click()
   Dim x As Integer     ' Local variable
      
   x = 6
   Print "Local x is " & x & " on entering cmdGo_click()"
   Print

   ' Call procedures
   Call One
   Call Two
   Call Three

   ' Call procedures again
   Call One
   Call Two
   Call Three

   Print "Local x is " & x & " on exiting cmdGo_click()"
   cmdGo.Enabled = False
End Sub

Private Sub One()
   Dim x As Integer

   x = 26
   Print "Local x is " & x & " on entering One"

   x = x + 1
   Print "Local x is " & x & " on exiting One"
   Print
End Sub

Private Sub Two()
   Static x As Integer

   ' Initialize local static x to 60
   ' the first time into the procedure
   If x = 0 Then
      x = 60
   End If

   Print "Local static x is " & x & " on entering Two"
   x = x + 1
   Print "Local static x is " & x & " on exiting Two"
   Print
End Sub

Private Sub Three()
   Print "Module x is " & x & " on entering Three"
   x = x + 5

   Print "Module x is " & x & " on exiting Three"
   Print
End Sub

⌨️ 快捷键说明

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