VERSION 5.00
Begin VB.Form frm1 
   BackColor       =   &H00404000&
   Caption         =   "Сортировка числового массива"
   ClientHeight    =   5535
   ClientLeft      =   2130
   ClientTop       =   1770
   ClientWidth     =   7830
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   9.75
      Charset         =   204
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H00FFFFFF&
   LinkTopic       =   "Form1"
   ScaleHeight     =   5535
   ScaleWidth      =   7830
   Begin VB.CommandButton cmdMin 
      Caption         =   "Мин. элемент"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1320
      TabIndex        =   4
      Top             =   1080
      Width           =   1695
   End
   Begin VB.TextBox txtDim 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   18
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2175
      Left            =   720
      MultiLine       =   -1  'True
      TabIndex        =   3
      Top             =   2280
      Width           =   3252
   End
   Begin VB.CommandButton cmdDim 
      Caption         =   "Заполнить массив"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1320
      TabIndex        =   2
      Top             =   4800
      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          =   3615
      Left            =   5040
      MultiLine       =   -1  'True
      TabIndex        =   1
      Top             =   840
      Width           =   2535
   End
   Begin VB.CommandButton cmdSort 
      Caption         =   "Сортировать"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   5640
      TabIndex        =   0
      Top             =   4800
      Width           =   1575
   End
   Begin VB.Label lbl2 
      Caption         =   "1 2 3 4 5 6 7 8 9 10"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   14.25
         Charset         =   204
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   3495
      Left            =   4680
      TabIndex        =   6
      Top             =   840
      Width           =   255
   End
   Begin VB.Label lbl1 
      Caption         =   "  Элементы массива    1 2 3 4 5 6 7 8 9 10"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   204
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   4920
      TabIndex        =   5
      Top             =   120
      Width           =   2655
   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 cmdDim_Click()
'заполнение массива
Randomize
For bytI = 1 To 10
bytA(bytI) = Int(Rnd * 10)
txtDim.Text = txtDim.Text + Str(bytA(bytI))
Next bytI
End Sub
Private Sub cmdMin_Click()
'событийная процедура поиска минимального элемента
bytMin = bytA(1)
For bytI = 2 To 10
If bytA(bytI) < bytMin Then bytMin = bytA(bytI): bytN = bytI
Next bytI
Print "Минимальный элемент "; bytMin; "  его индекс"; bytN
End Sub
Private Sub cmdSort_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


