Добрый вечер.
Ув. ветераны форума, помогите понять, почему при попытке отсортировать массив выбивает ошибку?
Private Sub test1()
Dim MyArray(5)
MyArray(1) = "Иван"
MyArray(2) = "Антон"
MyArray(3) = "Виктор"
MyArray(4) = "Яна"
MyArray(5) = "Костя"
Сортировка (MyArray)
End Sub
Private Sub Сортировка(List() As String)
Dim First As Integer
Dim Last As Integer
Dim I As Integer, j As Integer
Dim temp As String
First = LBound(List)
Last = UBound(List)
For I = First To Last - 1
For j = I + 1 To Last
If List(I) > List(j) Then
temp = List(j)
List(j) = List(I)
List(I) = temp
End If
Next j
Next I
End Sub
Ув. ветераны форума, помогите понять, почему при попытке отсортировать массив выбивает ошибку?
Private Sub test1()
Dim MyArray(5)
MyArray(1) = "Иван"
MyArray(2) = "Антон"
MyArray(3) = "Виктор"
MyArray(4) = "Яна"
MyArray(5) = "Костя"
Сортировка (MyArray)
End Sub
Private Sub Сортировка(List() As String)
Dim First As Integer
Dim Last As Integer
Dim I As Integer, j As Integer
Dim temp As String
First = LBound(List)
Last = UBound(List)
For I = First To Last - 1
For j = I + 1 To Last
If List(I) > List(j) Then
temp = List(j)
List(j) = List(I)
List(I) = temp
End If
Next j
Next I
End Sub
Изменено: 7Brod9ga - 30.03.2014 23:43:08