Sub cboClubList_Change()
Dim ÊîëÑòàíöèé As Integer Dim Ñòàíöèè() As String Dim p As Integer ÊîëÑòàíöèé = 1 ÍîìåðÑòðîêè = 2 ReDim Preserve Ñòàíöèè(1) As String While p = 0 If Trim(Cells(ÍîìåðÑòðîêè, 1).Value) = cboClubList.Value Then Ñòàíöèè(1) = Trim(Cells(ÍîìåðÑòðîêè, 2).Value) p = 3 End If ÍîìåðÑòðîêè = ÍîìåðÑòðîêè + 1 Wend 'Êóñîê êîäà âûøå ïðèñâàèâåò íà÷àëüíîå çíà÷åíèå ìàññèâó, êîòîðîå ñîîòâåòñâóåò óñëîâèþ âûáîðà çíà÷åíèÿ èç ïåðâîãî ComBoxa ÍîìåðÑòðîêè = 2 While Trim(Cells(ÍîìåðÑòðîêè, 2).Value) <> "" If Trim(Cells(ÍîìåðÑòðîêè, 1).Value) = cboClubList.Value Then Ñòàíöèÿ = Trim(Cells(ÍîìåðÑòðîêè, 2).Value) For j = 1 To ÊîëÑòàíöèé If Ñòàíöèÿ = Ñòàíöèè(j) Then GoTo n1 Next j ÊîëÑòàíöèé = ÊîëÑòàíöèé + 1 ReDim Preserve Ñòàíöèè(ÊîëÑòàíöèé) As String Ñòàíöèè(ÊîëÑòàíöèé) = Trim(Cells(ÍîìåðÑòðîêè, 2).Value) End If n1: ÍîìåðÑòðîêè = ÍîìåðÑòðîêè + 1 Wend ' Ñîñòàâëÿåì ñïèñîê ñòàíöèé, ïîäõîäÿùèè ïîä íàø êëóá For i = 1 To ÊîëÑòàíöèé - 1 Ñòàíöèÿ = Ñòàíöèè(i) k = i For j = i + 1 To ÊîëÑòàíöèé If Ñòàíöèè(j) >= Ñòàíöèÿ Then Else Ñòàíöèÿ = Ñòàíöèè(j) Ñòàíöèè(j) = Ñòàíöèè(k) Ñòàíöèè(k) = Ñòàíöèÿ End If Next Next i ' Ñîðòèðóåì ñïèñîê frmForma.cboMetroList.List = Ñòàíöèè frmForma.cboMetroList.ListIndex = 0
|