form1.frm

来自「vb电子书籍」· FRM 代码 · 共 56 行

FRM
56
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "错误处理"
   ClientHeight    =   2550
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6285
   LinkTopic       =   "Form1"
   ScaleHeight     =   2550
   ScaleWidth      =   6285
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command1 
      Caption         =   "调用函数"
      Height          =   495
      Left            =   2520
      TabIndex        =   0
      Top             =   1080
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'CODE Manger By BcodeXRose

'##################################################################
'## 函数名称:divide
'## 参数:number  类型不确定
'## 参数:denom  类型不确定
'As Variant'## 返回类型:As Variant
'##################################################################
Function divide(number, denom) As Variant
    Dim msg As String
    Const mnerrdivbyzero = 11
    Const mnerroverflow = 6
    Const mnerrbadcll = 5
    On Error GoTo mathhandler
    divide = number / denom
    Exit Function
mathhandler:
    If Err.number = mnerrdivbyzero Or Err.number = erroverflow Or Err = errbadcall Then
        divi = Null
    Else
        msg = "unanticipated error" & Err.number & ":" & Err.Description
        MsgBox msg, vbExclamation
    End If
    Resume Next
    
End Function

Private Sub Command1_Click()
  MsgBox Asc(divide(13, 12))
End Sub

⌨️ 快捷键说明

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