📄 mainform.vb
字号:
Option Strict On
Public Class MainForm
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 bttnAge As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents bttnAuxiliary 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.TextBox1 = New System.Windows.Forms.TextBox()
Me.bttnAge = New System.Windows.Forms.Button()
Me.bttnAuxiliary = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
Me.TextBox1.Location = New System.Drawing.Point(24, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(240, 23)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
'
'bttnAge
'
Me.bttnAge.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
Me.bttnAge.Location = New System.Drawing.Point(48, 56)
Me.bttnAge.Name = "bttnAge"
Me.bttnAge.Size = New System.Drawing.Size(192, 40)
Me.bttnAge.TabIndex = 0
Me.bttnAge.Text = "Show Dialog Box"
'
'bttnAuxiliary
'
Me.bttnAuxiliary.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte))
Me.bttnAuxiliary.Location = New System.Drawing.Point(48, 112)
Me.bttnAuxiliary.Name = "bttnAuxiliary"
Me.bttnAuxiliary.Size = New System.Drawing.Size(192, 40)
Me.bttnAuxiliary.TabIndex = 0
Me.bttnAuxiliary.Text = "Show Auxiliary Form"
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 205)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.bttnAuxiliary, Me.TextBox1, Me.bttnAge})
Me.Name = "MainForm"
Me.Text = "Main Form"
Me.ResumeLayout(False)
End Sub
#End Region
' to use the TBox shared variable, uncomment this declaration
' Make sure you edit the Form1_Load event handler as well
Public Shared TBox As TextBox
Public Shared strProperty As String = "Mastering VB.NET"
Dim DLG As New AgeDialog()
Dim WithEvents FRM As New AuxiliaryForm()
Private Sub bttnAge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnAge.Click
DLG.cmbDay.Text = "4"
DLG.cmbMonth.Text = "November"
DLG.cmbYear.Text = "1980"
DLG.ShowDialog()
If DLG.DialogResult = DialogResult.OK Then
MsgBox(DLG.cmbMonth.Text & " " & DLG.cmbDay.Text & ", " & DLG.cmbYear.Text)
Else
MsgBox("OK, we'll protect your vital personal data")
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = strProperty
' if you want to access the TextBox control on the main form
' through the TBox variable, uncomment the following line
'TBox = TextBox1
End Sub
Private Sub bttnAuxiliary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnAuxiliary.Click
FRM.Show()
End Sub
Private Sub FRM_strPropertyChanged() Handles FRM.strPropertyChanged
TextBox1.Text = strProperty
Beep()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
strProperty = TextBox1.Text
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -