Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Sorting array with VBS

$
0
0

I am reading data from file to array with For Next loop. I get the data to array but when I try to pass this unsorted array to bubblesort function I get type mismatch error. I don't understand why.

'This causes type mismatch

arrTestArray = BubbleSort(arrTestArray)

Function BubbleSort(arrValues)

    Dim j, k, Temp
    For j = 0 To UBound(arrValues) - 1
        For k = j + 1 To UBound(arrValues)
            If (arrValues(j) > arrValues(k)) Then
                Temp = arrValues(j)
                arrValues(j) = arrValues(k)
                arrValues(k) = Temp
            End If
        Next
    Next
 BubbleSort = arrValues
End Function


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>