L'ho scritta al volo, potrebbe contenere orrori...codice:Sub Ordina() Dim ElementiRiga(6) As String Dim ContatoreElementi As Integer Dim LunghezzaRiga As Integer Dim Record As String Dim i As Integer, j As Integer Const SeparatoreOutput = "," Const FineRecord = ";" Open "Disco:\Cartelle\File.Input" For Input As #1 Open "Disco:\Cartelle\File.Output" For Output As #1 While Not Eof(1) ContatoreElementi = 1 Line Input #1, Record LunghezzaRiga = Len(Record) ElementiRiga(ContatoreElementi) = "" 'separa numeri For i = 1 To LunghezzaRiga If IsNumeric(Mid(Record,i,1)) Then ElementiRiga(ContatoreElementi) = ElementiRiga(ContatoreElementi) & Mid(Record,i,1) Else ContatoreElementi = ContatoreElementi + 1 If ContatoreElementi > 5 Then ElementiRiga(ContatoreElementi) = "" End If End If Next i 'ordina For i = 1 To 4 For J = i+1 To 5 If CInt(ElementiRiga(j)) < CInt(ElementiRiga(i)) Then ElementiRiga(0) = ElementiRiga(j) ElementiRiga(j) = ElementiRiga(i) ElementiRiga(i) = ElementiRiga(0) End If Next J Next i 'scrivi For i = 1 To 5 Print #2, ElementoRiga(i), SeparatoreOutput; Next i Print #2, FineRecord Wend Close #1 Close #2 End Sub
Avrei potuto usare la split per dividere i numeri. Così funziona con qualsiasi separatore
![]()