📄 testform.vb
字号:
Public Class TestForm
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 Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents bttnInitTimer 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.Button2 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.bttnInitTimer = New System.Windows.Forms.Button()
Me.Button1 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.Location = New System.Drawing.Point(16, 40)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(176, 23)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Handle Exceptions"
'
'Button3
'
Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button3.Location = New System.Drawing.Point(16, 72)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(176, 23)
Me.Button3.TabIndex = 2
Me.Button3.Text = "Test Equals Method"
'
'bttnInitTimer
'
Me.bttnInitTimer.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnInitTimer.Location = New System.Drawing.Point(16, 104)
Me.bttnInitTimer.Name = "bttnInitTimer"
Me.bttnInitTimer.Size = New System.Drawing.Size(176, 23)
Me.bttnInitTimer.TabIndex = 3
Me.bttnInitTimer.Text = "Initialize Timer"
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.Location = New System.Drawing.Point(16, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(176, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Test Properties"
'
'TestForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(208, 141)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.bttnInitTimer, Me.Button3, Me.Button2, Me.Button1})
Me.Name = "TestForm"
Me.Text = "TestForm"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim obj1 As New Minimal()
Console.WriteLine(obj1.CountWords("The quick brown fox jumped over the lazy dog"))
obj1.property1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
obj1.property2 = 999999
Console.WriteLine(obj1.ReverseString)
Console.WriteLine(obj1.NegateNumber)
Dim obj2 As New Minimal()
obj2 = obj1
If obj1.Equals(obj2) Then Console.WriteLine("They're equal")
obj2.property1 = "abcdefghijklmnopqrstuvwxyz"
If obj1.Equals(obj2) Then Console.WriteLine("They're equal")
Console.WriteLine(obj1.CountWords("The quick brown fox jumped over the lazy dog"))
obj1.property1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
obj1.property2 = 999999
Console.WriteLine(obj1.ReverseString)
Console.WriteLine(obj1.NegateNumber)
obj1.BDate = #2/9/1952#
Console.WriteLine(obj1.Age)
obj1.BDate = #1/1/2900#
Console.WriteLine(obj1.Age)
Console.WriteLine(obj1.ToString)
Console.WriteLine(obj2.ToString)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim obj As New Minimal()
obj.property1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim obj2 As New Minimal()
Try
obj2.Age = 300
Catch exc As ArgumentException
MsgBox("Can't accept your value, will continue with default value of 30")
obj2.Age = 30
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
Dim obj As Minimal
obj = New Minimal()
obj.BDate = #2/9/1932#
Dim discount As Single
If obj.GetAgeGroup = Minimal.AgeGroup.Baby Or _
obj.GetAgeGroup = Minimal.AgeGroup.Toddler Then discount = 0.4
If obj.GetAgeGroup = Minimal.AgeGroup.Senior Then discount = 1.2
If obj.GetAgeGroup = Minimal.AgeGroup.Teenager Then discount = 0.25
Console.WriteLine(discount)
Dim O1 As New Minimal()
Dim O2 As New Minimal()
O1.BDate = #3/1/1960#
O2.BDate = #3/1/1960#
O1.property1 = "object1"
O2.property1 = "object2"
If O1.Equals(O2) Then
MsgBox("They're equal")
Else
MsgBox("They're not equal")
End If
End Sub
Dim WithEvents Timerobj As Minimal
Private Sub Timerobj_TeaTime(ByVal sender As System.Object) Handles Timerobj.TeaTime
MsgBox("It's tea time")
End Sub
Private Sub bttnInitTimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnInitTimer.Click
Timerobj = New Minimal()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -