排序.frm

来自「蒋加伏主编VB程序设计第四版PPT及全部课本源码 北京邮电大学出版社 」· FRM 代码 · 共 77 行

FRM
77
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "例[7-12] 用选择法排序"
   ClientHeight    =   1815
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3735
   LinkTopic       =   "Form1"
   ScaleHeight     =   1815
   ScaleWidth      =   3735
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "演示"
      Height          =   372
      Left            =   1440
      TabIndex        =   4
      Top             =   1320
      Width           =   972
   End
   Begin VB.Label Label4 
      BorderStyle     =   1  'Fixed Single
      Height          =   372
      Left            =   1200
      TabIndex        =   3
      Top             =   720
      Width           =   2172
   End
   Begin VB.Label Label3 
      Caption         =   "排序后:"
      Height          =   372
      Left            =   360
      TabIndex        =   2
      Top             =   720
      Width           =   972
   End
   Begin VB.Label Label2 
      BorderStyle     =   1  'Fixed Single
      Height          =   372
      Left            =   1200
      TabIndex        =   1
      Top             =   120
      Width           =   2172
   End
   Begin VB.Label Label1 
      Caption         =   "排序前:"
      Height          =   372
      Left            =   360
      TabIndex        =   0
      Top             =   240
      Width           =   972
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Base 1
Private Sub Command1_Click()
Dim a(6) As Integer
Dim k%, n%, i%, j%, t%
Randomize
n = 6
For i = 1 To n
    a(i) = Int(Rnd * 9) + 1
    Label2 = Label2 + Str(a(i))
Next i

For i = 1 To n - 1
    For j = n To i + 1 Step -1
        If a(j - 1) > a(j) Then t = a(j): a(j) = a(j - 1): a(j - 1) = t
    Next j
    Label4 = Label4 + Str(a(i))
Next i
Label4 = Label4 + Str(a(i))
End Sub

⌨️ 快捷键说明

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