Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, I'm not all that familiar with vba, and was wondering if there is something similiar to: 1) C++ Templates 2) C/C++ Passing functions as parameters I would like to have the equivalent of the qsort function from C/C++ (and I'd prefer not to have to specify Variant as the type, as I've heard that is slower). Thanks, Scott -- Maistrye ------------------------------------------------------------------------ Maistrye's Profile: http://www.excelforum.com/member.php...o&userid=36078 View this thread: http://www.excelforum.com/showthread...hreadid=573264 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I recently had to write a qsort for an array of 100000 numbers.
Perhaps this will point you in the right direction: Public Sub mySort() Dim x As Long Dim y As Long Dim idx As Long Dim Nums(0 To 99999) As Long 'load array For y = 1 To 4 For x = 1 To 25000 idx = (((y - 1) * 25000) + x) Nums(idx - 1) = CLng(Sheets("RECS2").Cells(x, y)) Next Next 'sort array Call quick(Nums(), 100000) End Sub Public Sub quick(myNums() As Long, count As Long) Call qs(myNums(), 0, (count - 1)) End Sub Public Sub qs(myNums() As Long, leftNum As Long, rightNum As Long) Dim i As Long Dim j As Long Dim x As Long Dim y As Long i = leftNum j = rightNum x = myNums((leftNum + rightNum) / 2) Do Do While myNums(i) < x And i < rightNum i = i + 1 Loop Do While x < myNums(j) And j leftNum j = j - 1 Loop If i <= j Then y = myNums(i) myNums(i) = myNums(j) myNums(j) = y i = i + 1 j = j - 1 End If Loop While i <= j If leftNum < j Then Call qs(myNums(), leftNum, j) End If If i < rightNum Then Call qs(myNums(), i, rightNum) End If End Sub -- Les Torchia-Wells "Maistrye" wrote: Hi, I'm not all that familiar with vba, and was wondering if there is something similiar to: 1) C++ Templates 2) C/C++ Passing functions as parameters I would like to have the equivalent of the qsort function from C/C++ (and I'd prefer not to have to specify Variant as the type, as I've heard that is slower). Thanks, Scott -- Maistrye ------------------------------------------------------------------------ Maistrye's Profile: http://www.excelforum.com/member.php...o&userid=36078 View this thread: http://www.excelforum.com/showthread...hreadid=573264 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I add functions in excel templates (XLT) | Excel Worksheet Functions | |||
Passing strings as arguments to xll functions. | Excel Programming | |||
passing targets between functions | Excel Programming | |||
passing arrays between functions in VBA | Excel Programming | |||
Passing parameters between functions | Excel Programming |