📄 frmbubbl.frm
字号:
VERSION 5.00
Begin VB.Form frmBubble
Caption = "Fig. 7.7: Bubble Sort"
ClientHeight = 4095
ClientLeft = 2595
ClientTop = 1590
ClientWidth = 5535
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 4095
ScaleWidth = 5535
Begin VB.CommandButton cmdGenerate
BackColor = &H80000005&
Caption = "Create Data"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 120
TabIndex = 0
Top = 3240
Width = 2055
End
Begin VB.ListBox lstSorted
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2460
Left = 3360
TabIndex = 4
Top = 600
Width = 1935
End
Begin VB.ListBox lstOriginal
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2460
Left = 120
TabIndex = 3
Top = 600
Width = 2055
End
Begin VB.CommandButton cmdExit
BackColor = &H80000005&
Caption = "Exit"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 3960
TabIndex = 2
Top = 3240
Width = 1335
End
Begin VB.CommandButton cmdSort
BackColor = &H80000005&
Caption = "Sort"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 2400
TabIndex = 1
Top = 3240
Width = 1335
End
Begin VB.Label lblSorted
Caption = "Sorted values:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3360
TabIndex = 6
Top = 240
Width = 2055
End
Begin VB.Label lblOriginal
Caption = "Original values:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 5
Top = 240
Width = 2055
End
End
Attribute VB_Name = "frmBubble"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 7.7
' Bubble Sort
Option Explicit
Option Base 1
Dim mArray(10) As Integer
Private Sub cmdGenerate_Click()
Dim x As Integer
Call Randomize ' Randomize Rnd
Call lstOriginal.Clear ' Clear data
Erase mArray ' Clear array
' Generate numbers
For x = LBound(mArray) To UBound(mArray)
mArray(x) = 1 + Int(100 * Rnd())
Call lstOriginal.AddItem(mArray(x))
Next x
Call lstSorted.Clear ' Clear ListBox
cmdSort.Enabled = True ' Enable Sort button
End Sub
Private Sub cmdSort_Click()
Dim x As Integer
Call lstSorted.Clear ' Clear ListBox
Call BubbleSort(mArray) ' Sort the array
For x = 1 To UBound(mArray)
Call lstSorted.AddItem(mArray(x))
Next x
cmdSort.Enabled = False
End Sub
Private Sub cmdExit_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -