Click here to Skip to main content
15,894,105 members
Articles / Programming Languages / XML

VB.NET Global Try Catch in the Application Framework

Rate me:
Please Sign up or sign in to vote.
4.92/5 (18 votes)
27 Jul 2018CPOL2 min read 68.5K   2.7K   40  
Implement a Global Try Catch block while still using the .NET Application Framework.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmDebug
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.lblSupport = New System.Windows.Forms.Label()
        Me.btnOk = New System.Windows.Forms.Button()
        Me.rtfError = New System.Windows.Forms.RichTextBox()
        Me.mnuRightClick = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.mnuCopy = New System.Windows.Forms.ToolStripMenuItem()
        Me.btnCopy = New System.Windows.Forms.Button()
        Me.mnuRightClick.SuspendLayout()
        Me.SuspendLayout()
        '
        'lblSupport
        '
        Me.lblSupport.AutoSize = True
        Me.lblSupport.Location = New System.Drawing.Point(12, 9)
        Me.lblSupport.Name = "lblSupport"
        Me.lblSupport.Size = New System.Drawing.Size(372, 21)
        Me.lblSupport.TabIndex = 0
        Me.lblSupport.Text = "Please provide support with a copy of this text:"
        '
        'btnOk
        '
        Me.btnOk.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnOk.BackColor = System.Drawing.Color.Transparent
        Me.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.btnOk.ForeColor = System.Drawing.Color.Black
        Me.btnOk.Location = New System.Drawing.Point(334, 379)
        Me.btnOk.Name = "btnOk"
        Me.btnOk.Size = New System.Drawing.Size(125, 32)
        Me.btnOk.TabIndex = 1
        Me.btnOk.Text = "Ok"
        Me.btnOk.UseVisualStyleBackColor = False
        '
        'rtfError
        '
        Me.rtfError.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
            Or System.Windows.Forms.AnchorStyles.Left) _
            Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.rtfError.ContextMenuStrip = Me.mnuRightClick
        Me.rtfError.Font = New System.Drawing.Font("Consolas", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.rtfError.Location = New System.Drawing.Point(14, 33)
        Me.rtfError.Name = "rtfError"
        Me.rtfError.ReadOnly = True
        Me.rtfError.Size = New System.Drawing.Size(445, 340)
        Me.rtfError.TabIndex = 2
        Me.rtfError.Text = ""
        Me.rtfError.WordWrap = False
        '
        'mnuRightClick
        '
        Me.mnuRightClick.BackColor = System.Drawing.Color.SteelBlue
        Me.mnuRightClick.Font = New System.Drawing.Font("Century Gothic", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.mnuRightClick.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuCopy})
        Me.mnuRightClick.Name = "mnuRightClick"
        Me.mnuRightClick.ShowImageMargin = False
        Me.mnuRightClick.Size = New System.Drawing.Size(195, 30)
        '
        'mnuCopy
        '
        Me.mnuCopy.ForeColor = System.Drawing.Color.White
        Me.mnuCopy.Name = "mnuCopy"
        Me.mnuCopy.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.C), System.Windows.Forms.Keys)
        Me.mnuCopy.Size = New System.Drawing.Size(194, 26)
        Me.mnuCopy.Text = "Copy Text"
        '
        'btnCopy
        '
        Me.btnCopy.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnCopy.BackColor = System.Drawing.Color.Transparent
        Me.btnCopy.ForeColor = System.Drawing.Color.Black
        Me.btnCopy.Location = New System.Drawing.Point(203, 379)
        Me.btnCopy.Name = "btnCopy"
        Me.btnCopy.Size = New System.Drawing.Size(125, 32)
        Me.btnCopy.TabIndex = 3
        Me.btnCopy.Text = "Copy Text"
        Me.btnCopy.UseVisualStyleBackColor = False
        '
        'frmDebug
        '
        Me.AcceptButton = Me.btnOk
        Me.AutoScaleDimensions = New System.Drawing.SizeF(10.0!, 21.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.BackColor = System.Drawing.Color.SteelBlue
        Me.ClientSize = New System.Drawing.Size(473, 423)
        Me.ContextMenuStrip = Me.mnuRightClick
        Me.ControlBox = False
        Me.Controls.Add(Me.btnCopy)
        Me.Controls.Add(Me.rtfError)
        Me.Controls.Add(Me.btnOk)
        Me.Controls.Add(Me.lblSupport)
        Me.Font = New System.Drawing.Font("Century Gothic", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ForeColor = System.Drawing.Color.White
        Me.Margin = New System.Windows.Forms.Padding(5)
        Me.Name = "frmDebug"
        Me.ShowIcon = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Global Try Catch Debug Output"
        Me.mnuRightClick.ResumeLayout(False)
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents lblSupport As System.Windows.Forms.Label
    Friend WithEvents btnOk As Button 'TigerView.Controls.Custom.Vista.VistaButton
    Friend WithEvents rtfError As System.Windows.Forms.RichTextBox
    Friend WithEvents btnCopy As Button 'TigerView.Controls.Custom.Vista.VistaButton
    Friend WithEvents mnuRightClick As System.Windows.Forms.ContextMenuStrip
    Friend WithEvents mnuCopy As System.Windows.Forms.ToolStripMenuItem
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions