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

📄 form1.frm

📁 排序算法演示系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "1"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   15.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Index           =   1
         Left            =   360
         TabIndex        =   20
         Top             =   1800
         Width           =   150
      End
      Begin VB.Label Label2 
         Alignment       =   1  'Right Justify
         BackStyle       =   0  'Transparent
         Caption         =   "B03040326 段安吉"
         Height          =   180
         Left            =   5760
         TabIndex        =   19
         Top             =   3360
         Width           =   1560
      End
      Begin VB.Line Line3 
         X1              =   240
         X2              =   7440
         Y1              =   2880
         Y2              =   2880
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   10
         Left            =   6720
         TabIndex        =   16
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   9
         Left            =   6000
         TabIndex        =   15
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   8
         Left            =   5280
         TabIndex        =   14
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   7
         Left            =   4560
         TabIndex        =   13
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   6
         Left            =   3840
         TabIndex        =   12
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   5
         Left            =   3120
         TabIndex        =   11
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   4
         Left            =   2400
         TabIndex        =   10
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   3
         Left            =   1680
         TabIndex        =   9
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   2
         Left            =   960
         TabIndex        =   8
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "000"
         BeginProperty Font 
            Name            =   "Arial Narrow"
            Size            =   18
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   1
         Left            =   240
         TabIndex        =   7
         Top             =   2280
         Width           =   735
      End
      Begin VB.Label Label99 
         Alignment       =   2  'Center
         BackStyle       =   0  'Transparent
         Caption         =   "当前排序:无"
         Height          =   180
         Index           =   0
         Left            =   2640
         TabIndex        =   6
         Top             =   1440
         Width           =   2385
      End
      Begin VB.Line Line2 
         X1              =   5040
         X2              =   7440
         Y1              =   1560
         Y2              =   1560
      End
      Begin VB.Line Line1 
         X1              =   240
         X2              =   2640
         Y1              =   1560
         Y2              =   1560
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim MyArray(10)

Private Sub Form_Load()

PP = 0.3

Form4.Show

Form4.Left = Form1.Left + Me.Width
Form4.Top = Form1.Top

End Sub

Private Sub isButton1_Click()

Label99(0).Caption = "当前排序:" + isButton1.Caption

gIterations = 0

Call GetMyArray

Call BubbleSort(MyArray())

End Sub

Private Sub isButton2_Click()

Label99(0).Caption = "当前排序:" + isButton2.Caption

gIterations = 0

Call GetMyArray

Call QuickSort(MyArray(), 1, 10)

End Sub

Private Sub isButton3_Click()

Label99(0).Caption = "当前排序:" + isButton3.Caption

gIterations = 0

Call GetMyArray

Call Insertion(MyArray)

End Sub

Private Sub isButton4_Click()

Label99(0).Caption = "当前排序:" + isButton4.Caption

gIterations = 0

Call GetMyArray

Call Selection(MyArray())

End Sub

Private Sub isButton6_Click()

Dim i
Randomize

'随机生成数列
For i = 1 To 10 Step 1
    Label1(i).Caption = CInt(Rnd() * 1000)
Next i

End Sub

'交换2个数
Public Function SwapAB(A, b)

Dim C

C = b
b = A
A = C

End Function

Sub GetMyArray()

For i = 1 To 10 Step 1
    MyArray(i) = CInt(Label1(i).Caption)
Next i

End Sub

'冒泡排序
Sub BubbleSort(MyArray())
LookLine (1)

Dim Index
LookLine (2)

Dim TEMP
LookLine (3)

Dim NextElement
LookLine (4)

 '先将已处理的元素个数置为0
 NextElement = ZERO
 LookLine (5)
 '遍历每一个元素
 Do While (NextElement < UBound(MyArray))
 LookLine (6)

 '读取当前最大下标
 Index = UBound(MyArray)
 LookLine (7)
 
 '与前面的每一个元素比较
 Do While (Index > NextElement)
 LookLine (8)
 
 If Index <> 1 Then
  Label3(Index).ForeColor = &HFF0000    '蓝色
  Label3(Index - 1).ForeColor = &HFF0000
 End If

 If MyArray(Index) < MyArray(Index - 1) Then
 LookLine (9)
 
 Label1(Index).ForeColor = &HFF& '红色
 Label1(Index - 1).ForeColor = &HFF&
 
 TEMP = MyArray(Index)
 LookLine (10)
 
 MyArray(Index) = MyArray(Index - 1)
 LookLine (11)
 
 Label1(Index) = Label1(Index - 1)

⌨️ 快捷键说明

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