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

📄 frmexfun.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmExitFunction 
   Caption         =   "Fig. 6.14: Demonstrating Exit Function"
   ClientHeight    =   3675
   ClientLeft      =   2430
   ClientTop       =   1710
   ClientWidth     =   5250
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H80000008&
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   3675
   ScaleWidth      =   5250
   Begin VB.TextBox txtDen 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   492
      Left            =   4080
      TabIndex        =   1
      Top             =   825
      Width           =   972
   End
   Begin VB.TextBox txtNum 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   492
      Left            =   4080
      TabIndex        =   0
      Top             =   120
      Width           =   972
   End
   Begin VB.CommandButton cmdDivide 
      BackColor       =   &H80000005&
      Caption         =   "Divide"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   1838
      TabIndex        =   2
      Top             =   2760
      Width           =   1575
   End
   Begin VB.Label lblThree 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   120
      TabIndex        =   5
      Top             =   1680
      Width           =   4935
   End
   Begin VB.Label lblTwo 
      Caption         =   "Enter second integer:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   90
      TabIndex        =   4
      Top             =   840
      Width           =   3615
   End
   Begin VB.Label lblOne 
      Caption         =   "Enter first integer:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   105
      TabIndex        =   3
      Top             =   120
      Width           =   3615
   End
End
Attribute VB_Name = "frmExitFunction"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 6.14
' Demonstrating Exit Function
Option Explicit       ' General declaration

Private Sub cmdDivide_Click()
   Dim numerator As Integer, denominator As Integer
   Dim result As String

   numerator = txtNum.Text
   denominator = txtDen.Text

   result = Divide(numerator, denominator)
   
   ' Value of result is "" if Exit Function executed
   If result = "" Then
      lblThree.Caption = "Divide by zero attempted!"
   Else
      lblThree.Caption = result    ' Display the String returned
   End If

End Sub

Private Function Divide(n As Integer, d As Integer) As String

   If d = 0 Then
      Exit Function   ' Exit the function returns ""
      Print "After Exit Function Line"    ' Never executed
   Else
      Divide = "Division yields " & n / d
   End If

End Function

⌨️ 快捷键说明

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