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

📄 auxiliaryform.vb

📁 Mastering VBNet Include Source Code
💻 VB
字号:
Option Strict On
Public Class AuxiliaryForm
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    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
    Friend WithEvents bttnReadShared As System.Windows.Forms.Button
    Friend WithEvents bttnSetShared As System.Windows.Forms.Button

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

    '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.bttnSetShared = New System.Windows.Forms.Button()
        Me.bttnReadShared = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'bttnSetShared
        '
        Me.bttnSetShared.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
        Me.bttnSetShared.Location = New System.Drawing.Point(48, 136)
        Me.bttnSetShared.Name = "bttnSetShared"
        Me.bttnSetShared.Size = New System.Drawing.Size(192, 56)
        Me.bttnSetShared.TabIndex = 0
        Me.bttnSetShared.Text = "Set Shared Variable in Main Form"
        '
        'bttnReadShared
        '
        Me.bttnReadShared.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
        Me.bttnReadShared.Location = New System.Drawing.Point(48, 64)
        Me.bttnReadShared.Name = "bttnReadShared"
        Me.bttnReadShared.Size = New System.Drawing.Size(192, 56)
        Me.bttnReadShared.TabIndex = 0
        Me.bttnReadShared.Text = "Read Shared Variable in Main Form"
        '
        'AuxiliaryForm
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.bttnSetShared, Me.bttnReadShared})
        Me.Name = "AuxiliaryForm"
        Me.Text = "AuxiliaryForm"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Event strPropertyChanged()
    Private Sub bttnReadShared_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnReadShared.Click
        MsgBox(MainForm.strProperty, MsgBoxStyle.OKOnly, "Public Variable Value")
        ' IF YOU WANT TO ACCESS THE TEXTBOX CONTROL ON THE MAIN FORM 
        ' THROUGH THE TBOX SHARED VARIABLE, COMMENT OUT THE FIRST LINE
        ' IN THIS SUBROUTINE AND UNCOMMENT THE FOLLOWING TWO LINES
        'Dim Main As MainForm
        'MsgBox(Main.TBox.Text)
    End Sub

    Private Sub bttnSetShared_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnSetShared.Click
        Dim str As String
        str = InputBox("Enter a new value for strProperty")
        MainForm.strProperty = str
        RaiseEvent strPropertyChanged()
    End Sub

    Private Sub AuxiliaryForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Me.Hide()
        e.Cancel = True
    End Sub
End Class

⌨️ 快捷键说明

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