VERSION 5.00
Begin VB.Form frm1 
   BackColor       =   &H00404000&
   Caption         =   "Сортировка числового массива"
   ClientHeight    =   3288
   ClientLeft      =   2124
   ClientTop       =   1764
   ClientWidth     =   4668
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   9.6
      Charset         =   204
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H00FFFFFF&
   LinkTopic       =   "Form1"
   ScaleHeight     =   3288
   ScaleWidth      =   4668
   Begin VB.CommandButton cmd1 
      Caption         =   "Заполнить массив"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   7.8
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2640
      TabIndex        =   2
      Top             =   720
      Width           =   1695
   End
   Begin VB.TextBox txtSort 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2892
      Left            =   360
      MultiLine       =   -1  'True
      TabIndex        =   1
      Top             =   120
      Width           =   2052
   End
   Begin VB.CommandButton cmd2 
      Caption         =   "Сортировать"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   7.8
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2640
      TabIndex        =   0
      Top             =   2040
      Width           =   1692
   End
End
Attribute VB_Name = "frm1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim bytA(1 To 10), bytMin, bytI, bytJ, bytK, bytR, bytN As Byte
'общая процедура поиска минимального элемента
Sub МинЭлемент(bytJ, bytN As Byte)
bytMin = bytA(bytI)
bytN = bytI
For bytJ = bytI + 1 To 10
If bytA(bytJ) < bytMin Then bytMin = bytA(bytJ): bytN = bytJ
Next bytJ
End Sub
'заполнение массива
Private Sub cmd1_Click()
For bytI = 1 To 10
bytA(bytI) = Int(Rnd * 10)
Next bytI
End Sub
'событийная процедура сортировки
Private Sub cmd2_Click()
txtSort.Text = ""
For bytI = 1 To 9
'вызов общей процедуры поиска минимального элемента
Call МинЭлемент(bytJ, bytN)
'перестановка
bytR = bytA(bytI)
bytA(bytI) = bytA(bytN)
bytA(bytN) = bytR
'печать массива для каждого цикла перестановки
For bytK = 1 To 10
txtSort.Text = txtSort.Text + Str(bytA(bytK))
Next bytK
Next bytI
End Sub


