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

📄 frmoptionalargs.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmOptionalArgs 
   Caption         =   "Fig. 6.29: Demonstrating Optional Arguments"
   ClientHeight    =   2355
   ClientLeft      =   2700
   ClientTop       =   1980
   ClientWidth     =   4995
   BeginProperty Font 
      Name            =   "Courier"
      Size            =   12
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   ScaleHeight     =   2355
   ScaleWidth      =   4995
   Begin VB.CommandButton cmdPrint 
      Caption         =   "Print"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1890
      TabIndex        =   0
      Top             =   1800
      Width           =   1215
   End
End
Attribute VB_Name = "frmOptionalArgs"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 6.29
' Demonstrating optional arguments
Option Explicit              ' General declaration

Private Sub cmdPrint_Click()
   Call Cls
   
   Call BoxVolume            ' Default 3 arguments
   Call BoxVolume(8)         ' Default 2 arguments
   Call BoxVolume(6, 7)      ' Default 1 argument
   Call BoxVolume(2, 3, 4)   ' Pass 3 arguments
   Call BoxVolume(1, , 9)    ' Default 1 argument
   Call BoxVolume(, 5)       ' Default 2 arguments
   Call BoxVolume(, , 0)     ' Default 2 arguments
End Sub

Private Sub BoxVolume(Optional x As Integer = 1, _
                      Optional y As Integer = 1, _
                      Optional z As Integer = 1)
                      
   Print "Dimensions: " & x & ", " & y & ", " & z & Space$(5) & _
                      "Volume: " & (x * y * z)
End Sub

⌨️ 快捷键说明

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