Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 17th, 2007, 01:34 AM
sanjayt sanjayt is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 4 sanjayt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 30 sec
Reputation Power: 0
Out of stack problem..

hi all,

I m creating a macro that performs sorting.I m using quicksort algoritm.Its working fine for data below 5000 but as soon as data exceeds beyond it .
It shows Run-time error - 28 out of stack.
Is there any way to avoid too many recursion??
Please help me out...






Sub RecursiveSort(ByVal llow As Long, ByVal lHigh As Long)
Dim lStart As Long
Dim lEnd As Long
Dim vTemp As Variant
Dim vPivot As Variant
lStart = lHigh
lEnd = llow
vPivot = a_vRowElements(lEnd)
'Till the count is less or equal to the max limit
Do While lEnd <= lStart

If bChkFlag = True Then
' While a_vRowElements(lEnd) < vPivot
While Compare(a_vRowElements(lEnd), vPivot)
lEnd = lEnd + 1
Wend
'While a_vRowElements(lStart) > vPivot
While Compare(vPivot, a_vRowElements(lStart))
lStart = lStart - 1
Wend
Else
'While a_vRowElements(lEnd) > vPivot
While Compare(vPivot, a_vRowElements(lEnd))
lEnd = lEnd + 1
Wend
'While a_vRowElements(lStart) < vPivot
While Compare(a_vRowElements(lStart), vPivot)
lStart = lStart - 1
Wend

End If
'
If lStart >= lEnd Then
If lStart <> lEnd Then
vTemp = a_vRowElements(lEnd)
a_vRowElements(lEnd) = a_vRowElements(lStart)
a_vRowElements(lStart) = vTemp
End If
lStart = lStart - 1
lEnd = lEnd + 1
End If
Loop
If llow <= lStart Then
RecursiveSort llow, lStart
End If
If lEnd < lHigh Then
RecursiveSort lEnd, lHigh
End If
End Sub

Reply With Quote
  #2  
Old December 17th, 2007, 03:38 PM
Wolffy's Avatar
Wolffy Wolffy is offline
Slaprentice of Wolves
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Aug 2007
Location: Mossville, IL
Posts: 1,467 Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level)Wolffy User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 1 h 42 m 14 sec
Reputation Power: 519
Quote:
Originally Posted by sanjayt
hi all,

I m creating a macro that performs sorting.I m using quicksort algoritm.Its working fine for data below 5000 but as soon as data exceeds beyond it .
It shows Run-time error - 28 out of stack.
Is there any way to avoid too many recursion??
Please help me out...






Sub RecursiveSort(ByVal llow As Long, ByVal lHigh As Long)
Dim lStart As Long
Dim lEnd As Long
Dim vTemp As Variant
Dim vPivot As Variant
lStart = lHigh
lEnd = llow
vPivot = a_vRowElements(lEnd)
'Till the count is less or equal to the max limit
Do While lEnd <= lStart

If bChkFlag = True Then
' While a_vRowElements(lEnd) < vPivot
While Compare(a_vRowElements(lEnd), vPivot)
lEnd = lEnd + 1
Wend
'While a_vRowElements(lStart) > vPivot
While Compare(vPivot, a_vRowElements(lStart))
lStart = lStart - 1
Wend
Else
'While a_vRowElements(lEnd) > vPivot
While Compare(vPivot, a_vRowElements(lEnd))
lEnd = lEnd + 1
Wend
'While a_vRowElements(lStart) < vPivot
While Compare(a_vRowElements(lStart), vPivot)
lStart = lStart - 1
Wend

End If
'
If lStart >= lEnd Then
If lStart <> lEnd Then
vTemp = a_vRowElements(lEnd)
a_vRowElements(lEnd) = a_vRowElements(lStart)
a_vRowElements(lStart) = vTemp
End If
lStart = lStart - 1
lEnd = lEnd + 1
End If
Loop
If llow <= lStart Then
RecursiveSort llow, lStart
End If
If lEnd < lHigh Then
RecursiveSort lEnd, lHigh
End If
End Sub

Quicksort is a horrid sorting algorithm that requires lots of memory and time. There are better sorts available.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. Not FDIC insured

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Out of stack problem..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT