📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim lVar1 As Long
Dim lVar2 As Long = 0
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents bnMessage As System.Windows.Forms.Button
Friend WithEvents bnSource As System.Windows.Forms.Button
Friend WithEvents bnToString As System.Windows.Forms.Button
Friend WithEvents bnAllErrors As System.Windows.Forms.Button
Friend WithEvents bnOthers As System.Windows.Forms.Button
Friend WithEvents bnUsers As System.Windows.Forms.Button
Friend WithEvents txtErrorMsg As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.bnMessage = New System.Windows.Forms.Button()
Me.bnSource = New System.Windows.Forms.Button()
Me.bnToString = New System.Windows.Forms.Button()
Me.bnAllErrors = New System.Windows.Forms.Button()
Me.bnOthers = New System.Windows.Forms.Button()
Me.bnUsers = New System.Windows.Forms.Button()
Me.txtErrorMsg = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'bnMessage
'
Me.bnMessage.Location = New System.Drawing.Point(56, 16)
Me.bnMessage.Name = "bnMessage"
Me.bnMessage.Size = New System.Drawing.Size(80, 24)
Me.bnMessage.TabIndex = 0
Me.bnMessage.Text = "Message"
'
'bnSource
'
Me.bnSource.Location = New System.Drawing.Point(56, 56)
Me.bnSource.Name = "bnSource"
Me.bnSource.Size = New System.Drawing.Size(80, 24)
Me.bnSource.TabIndex = 1
Me.bnSource.Text = "Source"
'
'bnToString
'
Me.bnToString.Location = New System.Drawing.Point(56, 96)
Me.bnToString.Name = "bnToString"
Me.bnToString.Size = New System.Drawing.Size(80, 24)
Me.bnToString.TabIndex = 2
Me.bnToString.Text = "ToString"
'
'bnAllErrors
'
Me.bnAllErrors.Location = New System.Drawing.Point(56, 136)
Me.bnAllErrors.Name = "bnAllErrors"
Me.bnAllErrors.Size = New System.Drawing.Size(80, 24)
Me.bnAllErrors.TabIndex = 3
Me.bnAllErrors.Text = "AllErrors"
'
'bnOthers
'
Me.bnOthers.Location = New System.Drawing.Point(56, 176)
Me.bnOthers.Name = "bnOthers"
Me.bnOthers.Size = New System.Drawing.Size(80, 24)
Me.bnOthers.TabIndex = 4
Me.bnOthers.Text = "Others"
'
'bnUsers
'
Me.bnUsers.Location = New System.Drawing.Point(56, 216)
Me.bnUsers.Name = "bnUsers"
Me.bnUsers.Size = New System.Drawing.Size(80, 24)
Me.bnUsers.TabIndex = 5
Me.bnUsers.Text = "Users"
'
'txtErrorMsg
'
Me.txtErrorMsg.Location = New System.Drawing.Point(152, 216)
Me.txtErrorMsg.Name = "txtErrorMsg"
Me.txtErrorMsg.Size = New System.Drawing.Size(96, 21)
Me.txtErrorMsg.TabIndex = 6
Me.txtErrorMsg.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtErrorMsg, Me.bnUsers, Me.bnOthers, Me.bnAllErrors, Me.bnToString, Me.bnSource, Me.bnMessage})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub bnMessage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnMessage.Click
Try
lVar1 = 8 / lVar2
Catch eErr As System.Exception
MsgBox(eErr.Message)
End Try
End Sub
Private Sub bnSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnSource.Click
Try
lVar1 = 8 / lVar2
Catch eErr As System.Exception
MsgBox(eErr.Source)
End Try
End Sub
Private Sub bnToString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnToString.Click
Try
lVar1 = 8 / lVar2
Catch eErr As System.Exception
MsgBox(eErr.ToString())
End Try
End Sub
Private Sub bnAllErrors_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnAllErrors.Click
Try
lVar1 = 8 / lVar2
Catch
MsgBox("错误")
End Try
End Sub
Private Sub bnOthers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnOthers.Click
Try
lVar1 = 8 / lVar2
Catch eErr As NullReferenceException
MsgBox("错误")
End Try
End Sub
Private Sub HaveValue()
Dim MyError As New Exception("Text Box不可空白")
MyError.Source = "HaveValue"
If txtErrorMsg.Text.Length = 0 Then
Throw MyError
End If
End Sub
Private Sub bnUsers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnUsers.Click
Try
HaveValue()
lVar1 = 8 / lVar2
Catch eErr As OverflowException
MsgBox(txtErrorMsg.Text)
Catch eErr As Exception
MsgBox("有错误发生啦!" & vbCrLf & eErr.Source & vbCrLf & eerr.Message)
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -