Date: 02-16-2022
Return to Index
created by gbSnippets
'Compiler Comments:
'This code was written to compile in PBWin10. To compile in PBWin9,
'replace CALL with USING in the Array Sort statements (1 places).
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Type MyType : x as Long : z as Long : End Type
Function PBMain() As Long
Local DXin$, DXout$, DZin$, DZOut$, i As Long
Dim D(5) As MyType
D(0).x = 5 : D(0).z = 10
D(1).x = 4 : D(1).z = 11
D(2).x = 3 : D(2).z = 12
D(3).x = 2 : D(3).z = 13
D(4).x = 1 : D(4).z = 14
D(5).x = 0 : D(5).z = 15
Array Sort D(), Call CustomSort
For i = 0 to 5 : DXout$ = DXout$ + Str$(D(i).x) : DZout$ = DZOut$ + Str$(D(i).z) : Next i
MsgBox DXin$ + $crlf + DXout$ + $crlf + $crlf + DZin$ + $crlf + DZOut$
End Function
Function CustomSort(R As MyType, S as MyType) As Long
If R.x < S.x Then Function = -1 : Exit Function
If R.x > S.x Then Function = +1 : Exit Function
End Function
'gbs_00563
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm