Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
Enum Equates Singular
IDC_Button
End Enum
Global hDlg As Dword, MyArray() As String
Function PBMain() As Long
Local temp$, i As Long
ReDim MyArray(2,2)
Array Assign MyArray() = "c ","a ","b ", _ 'column 0, row 0,1,2
"k ","j ","l ", _ 'column 1, row 0,1,2
"r ","s ","q " 'column 2, row 0,1,2
For i = 0 To 2 : temp$ += MyArray(i,0) + MyArray(i,1) + MyArray(i,2) + $CrLf : Next i
temp$ += $CrLf
BubbleSort 0
For i = 0 To 2 : temp$ += MyArray(i,0) + MyArray(i,1) + MyArray(i,2) + $CrLf : Next i
? temp$
End Function
Sub BubbleSort(iCol As Long)
Local i,j,k As Long
For i = LBound(MyArray,1) To UBound(MyArray,1)-1
For j = i+1 To UBound(MyArray,1)
If MyArray(i,iCol) > MyArray(j,iCol) Then
For k = LBound(MyArray,2) To UBound(Myarray,2)
Swap MyArray(i,k), MyArray(j,k)
Next k
End If
Next j
Next j
End Sub
http://www.garybeene.com/sw/gbsnippets.htm