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

📄 编程补充题2.frm

📁 一本学习Visual Basic编程的好书
💻 FRM
字号:
VERSION 5.00
Begin VB.Form form1 
   Caption         =   "起泡排序法演示"
   ClientHeight    =   3360
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3465
   LinkTopic       =   "Form1"
   ScaleHeight     =   3360
   ScaleWidth      =   3465
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "排序"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1875
      TabIndex        =   8
      Top             =   1320
      Width           =   975
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Height          =   270
      Index           =   8
      Left            =   360
      TabIndex        =   7
      Text            =   " "
      Top             =   2760
      Width           =   735
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Height          =   270
      Index           =   7
      Left            =   375
      TabIndex        =   6
      Text            =   " "
      Top             =   2400
      Width           =   735
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Height          =   270
      Index           =   6
      Left            =   360
      TabIndex        =   5
      Text            =   " "
      Top             =   2040
      Width           =   735
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Height          =   270
      Index           =   5
      Left            =   360
      TabIndex        =   4
      Text            =   " "
      Top             =   1680
      Width           =   735
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Height          =   270
      Index           =   4
      Left            =   360
      TabIndex        =   3
      Text            =   " "
      Top             =   1320
      Width           =   735
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Height          =   270
      Index           =   3
      Left            =   360
      TabIndex        =   2
      Text            =   " "
      Top             =   960
      Width           =   735
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Height          =   270
      Index           =   2
      Left            =   360
      TabIndex        =   1
      Text            =   " "
      Top             =   600
      Width           =   735
   End
   Begin VB.TextBox Text1 
      Alignment       =   2  'Center
      Height          =   270
      Index           =   1
      Left            =   360
      TabIndex        =   0
      Text            =   " "
      Top             =   240
      Width           =   735
   End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const n = 8                              '声明符号常量
Option Base 1
Private Sub Form_Load()
   Randomize
   For i = 1 To n                        '产生n 个随机数
      Text1(i).ForeColor = RGB(0, 0, 0)      '用黑色显示
      Text1(i).Text = Int(90 * Rnd + 10)
   Next i
End Sub
Private Sub Command1_Click()
   For j = 1 To n - 1                    '外循环
      MsgBox "准备进行第" + Str(j) + "次比较,按回车键继续"
      For i = 1 To n - j                 '内循环
        If Val(Text1(i).Text) > Val(Text1(i + 1).Text) Then
           t = Text1(i).Text
           Text1(i).Text = Text1(i + 1).Text
           Text1(i + 1).Text = t
        End If
      Next i
      Text1(n - j + 1).ForeColor = RGB(255, 0, 0) '沉底数用红色表示
   Next j
   MsgBox "排序完毕"
End Sub

⌨️ 快捷键说明

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