Showing posts with label Array. Show all posts
Showing posts with label Array. Show all posts
Friday, February 17, 2012
Array sorting procedure
'------------------------------------------------------------------------
Private Sub SortArray(arr() As Integer)
'------------------------------------------------------------------------
'This sub uses the Bubble Sort algorithm to sort an array of integers.
Dim lngX As Long
Dim lngY As Long
Dim tmp As Integer
For lngX = LBound(arr) To (UBound(arr) - 1)
For lngY = LBound(arr) To (UBound(arr) - 1)
If arr(lngY) > arr(lngY + 1) Then
'exchange the items
tmp = arr(lngY)
arr(lngY) = arr(lngY + 1)
arr(lngY + 1) = tmp
End If
Next lngY
Next lngX
End Sub
Monday, February 13, 2012
Check existing value in array
Function InSArray(ByRef vArray() As String, ByVal vValue As String) As Boolean
'***Return true, if found this value in array***'
'***Return false, if not found this value in array***'
Dim i As Long
For i = LBound(vArray) To UBound(vArray)
If vArray(i) = vValue Then
InSArray = True
Exit Function
End If
Next i
InSArray = False
End Function
Subscribe to:
Comments (Atom)