📄 form1.vb
字号:
Public Class Form1
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 lblHead1 As System.Windows.Forms.Label
Friend WithEvents lblHead2 As System.Windows.Forms.Label
Friend WithEvents btnSort As System.Windows.Forms.Button
Friend WithEvents lbl3 As System.Windows.Forms.Label
Friend WithEvents lbl4 As System.Windows.Forms.Label
Friend WithEvents txt1 As System.Windows.Forms.TextBox
Friend WithEvents txt2 As System.Windows.Forms.TextBox
Friend WithEvents txt0 As System.Windows.Forms.TextBox
Friend WithEvents txt3 As System.Windows.Forms.TextBox
Friend WithEvents txt4 As System.Windows.Forms.TextBox
Friend WithEvents lbl0 As System.Windows.Forms.Label
Friend WithEvents lbl1 As System.Windows.Forms.Label
Friend WithEvents lbl2 As System.Windows.Forms.Label
'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.lbl3 = New System.Windows.Forms.Label
Me.lbl4 = New System.Windows.Forms.Label
Me.txt1 = New System.Windows.Forms.TextBox
Me.txt2 = New System.Windows.Forms.TextBox
Me.txt0 = New System.Windows.Forms.TextBox
Me.txt3 = New System.Windows.Forms.TextBox
Me.btnSort = New System.Windows.Forms.Button
Me.lblHead1 = New System.Windows.Forms.Label
Me.lblHead2 = New System.Windows.Forms.Label
Me.txt4 = New System.Windows.Forms.TextBox
Me.lbl0 = New System.Windows.Forms.Label
Me.lbl1 = New System.Windows.Forms.Label
Me.lbl2 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'lbl3
'
Me.lbl3.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lbl3.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lbl3.Location = New System.Drawing.Point(278, 67)
Me.lbl3.Name = "lbl3"
Me.lbl3.Size = New System.Drawing.Size(48, 23)
Me.lbl3.TabIndex = 2
'
'lbl4
'
Me.lbl4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lbl4.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lbl4.Location = New System.Drawing.Point(336, 67)
Me.lbl4.Name = "lbl4"
Me.lbl4.Size = New System.Drawing.Size(48, 23)
Me.lbl4.TabIndex = 2
'
'txt1
'
Me.txt1.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.txt1.Location = New System.Drawing.Point(163, 22)
Me.txt1.Name = "txt1"
Me.txt1.Size = New System.Drawing.Size(48, 24)
Me.txt1.TabIndex = 1
Me.txt1.Text = ""
'
'txt2
'
Me.txt2.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.txt2.Location = New System.Drawing.Point(221, 22)
Me.txt2.Name = "txt2"
Me.txt2.Size = New System.Drawing.Size(48, 24)
Me.txt2.TabIndex = 2
Me.txt2.Text = ""
'
'txt0
'
Me.txt0.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.txt0.Location = New System.Drawing.Point(106, 22)
Me.txt0.Name = "txt0"
Me.txt0.Size = New System.Drawing.Size(48, 24)
Me.txt0.TabIndex = 0
Me.txt0.Text = ""
'
'txt3
'
Me.txt3.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.txt3.Location = New System.Drawing.Point(278, 22)
Me.txt3.Name = "txt3"
Me.txt3.Size = New System.Drawing.Size(48, 24)
Me.txt3.TabIndex = 3
Me.txt3.Text = ""
'
'btnSort
'
Me.btnSort.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.btnSort.Location = New System.Drawing.Point(413, 22)
Me.btnSort.Name = "btnSort"
Me.btnSort.Size = New System.Drawing.Size(67, 23)
Me.btnSort.TabIndex = 3
Me.btnSort.Text = "排序"
'
'lblHead1
'
Me.lblHead1.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lblHead1.Location = New System.Drawing.Point(19, 22)
Me.lblHead1.Name = "lblHead1"
Me.lblHead1.Size = New System.Drawing.Size(87, 23)
Me.lblHead1.TabIndex = 0
Me.lblHead1.Text = "排序前"
'
'lblHead2
'
Me.lblHead2.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lblHead2.Location = New System.Drawing.Point(19, 67)
Me.lblHead2.Name = "lblHead2"
Me.lblHead2.Size = New System.Drawing.Size(87, 23)
Me.lblHead2.TabIndex = 0
Me.lblHead2.Text = "排序后"
'
'txt4
'
Me.txt4.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.txt4.Location = New System.Drawing.Point(336, 22)
Me.txt4.Name = "txt4"
Me.txt4.Size = New System.Drawing.Size(48, 24)
Me.txt4.TabIndex = 4
Me.txt4.Text = ""
'
'lbl0
'
Me.lbl0.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lbl0.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lbl0.Location = New System.Drawing.Point(106, 67)
Me.lbl0.Name = "lbl0"
Me.lbl0.Size = New System.Drawing.Size(48, 23)
Me.lbl0.TabIndex = 2
'
'lbl1
'
Me.lbl1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lbl1.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lbl1.Location = New System.Drawing.Point(163, 67)
Me.lbl1.Name = "lbl1"
Me.lbl1.Size = New System.Drawing.Size(48, 23)
Me.lbl1.TabIndex = 2
'
'lbl2
'
Me.lbl2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.lbl2.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lbl2.Location = New System.Drawing.Point(221, 67)
Me.lbl2.Name = "lbl2"
Me.lbl2.Size = New System.Drawing.Size(48, 23)
Me.lbl2.TabIndex = 2
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(489, 109)
Me.Controls.Add(Me.btnSort)
Me.Controls.Add(Me.lbl3)
Me.Controls.Add(Me.lbl2)
Me.Controls.Add(Me.lbl4)
Me.Controls.Add(Me.lbl1)
Me.Controls.Add(Me.lbl0)
Me.Controls.Add(Me.txt3)
Me.Controls.Add(Me.txt4)
Me.Controls.Add(Me.txt2)
Me.Controls.Add(Me.txt1)
Me.Controls.Add(Me.txt0)
Me.Controls.Add(Me.lblHead2)
Me.Controls.Add(Me.lblHead1)
Me.Name = "Form1"
Me.Text = "f10_3_1"
Me.ResumeLayout(False)
End Sub
#End Region
'************** f10_3_1 **************
Private Sub btnSort_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSort.Click
Dim a(4) As Integer
Dim i, j, t As Integer
a(0) = txt0.Text : a(1) = txt1.Text
a(2) = txt2.Text : a(3) = txt3.Text
a(4) = txt4.Text
For i = 3 To 0 Step -1
For j = 0 To i
If a(j) > a(j + 1) Then
t = a(j)
a(j) = a(j + 1)
a(j + 1) = t
End If
Next j
Next i
lbl0.Text = a(0) : lbl1.Text = a(1)
lbl2.Text = a(2) : lbl3.Text = a(3)
lbl4.Text = a(4)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -