out of stack space

This is a repetitive question, but still im not able to solve. I get run time error 28, out of stack space.
The solution is remove recursive loops. I have lot of small functions, i dont know exactly where the error occurs. Its does'nt show the line numbers.. How can i trace the line number in dll
sureshrao72Asked:
Who is Participating?
 
inthedarkCommented:
I would propose a small improvement rspahitz's idea:

' In your code
IF GF.IDE Then
   On Error GoTo 0 ' Allow to crash when debugging
Else
   On Error Goto ErrorTrap
End If

' now perform your tasks.....


ErrorTrap:
  ErrNum = Err.Number
  ErrDesc = Err.Description
  ErrLine = Erl
  IF GF.IDE Then
      On Error GoTo 0 ' Allow to crash when debugging using the IDE
  Else
     On error resume next ' Stop looping back to ErrorTrap
  End If

now handle fault etc......

===========

Create a class module named zGF. Place all your handy subs and functions in the module. (You may already do this.)

In you app. create a module and include:

Global GF as New zGF

Now if you type "GF." you get a list of your handy functions


==========Here is the code for the zGF module

Option Explicit

Dim mIDEDone As Boolean
Dim mIDE As Boolean

Public Function IDE() As Boolean

' Returns True if running in debug (IDE) mode
'         False if running in an EXE

'Example:
' If ADO.IDE Then Stop

If Not mIDEDone Then ' See below
'To make this function work you need the following in your
' class declarations:
'Dim mIDEDone As Boolean
'Dim mIDE As Boolean

    ' just do this first time round then store the result
    On Error Resume Next
    Err.Clear
    Debug.Print 1 / 0
    If Err.Number <> 0 Then
        mIDE = True
    Else
        mIDE = False
    End If
    mIDEDone = True
End If

IDE = mIDE

End Function
0
 
rspahitzCommented:
You can add line numbers if you want, since they are still supported, but simply deprecated and probably removed in .NET.

Example:

Private sub TestLineNumbers()
  dim somevar as integer
  dim anothervar as string

10
  on error goto TestLineNumbers_Err

20
  do while not eof(1)
    line input #1, dataline
  loop

30
  for i=1 to len(dataline)
40
    temp = mid$(dataline,i,1)
    if temp = "a" then
50      debug.print "A"
    else
60      debug.print temp
    endif
  next i
  exit sub
TestLineNumbers_Err:
  msgbox "Error occured somewhere after line " & erl
end sub

'
The line numbers can be placed before anyline, either on their own, or as a prefix to a line, and they can range from 1 to 32767.
0
 
Anthony PerkinsCommented:
Please maintain your open questions:

Questions Asked 8
Last 10 Grades Given B B B C  
Question Grading Record 4 Answers Graded / 4 Answers Received

Thanks,
Anthony
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
adgCommented:
When you get the error, can you use the view call stack option to see what happened?
0
 
inthedarkCommented:
You can also get out of stack space if you use Gosub like:



MyStrangeLoop:

'do some code

Gosub MyStrangeLoop

' never gets here
' do some more

Return

0
 
inthedarkCommented:
DLL's are hard to debug, especially when running on a web-server, you don't get to see the error message so you must never allow the software to crash.

I always dump all errors into a log file formatted with HTML and get the error logging routine to send me an e-mail message with the error detail.  The idea is that you can repair the fault before the boss finds out. Also its important to log the user ID so you know who to apologize to.

adg's idea is good for debug mode but in a live environment it won't help.

At the start of all Subs and functions you can place code like.

Function MyFunction()
Dim Stage as Long
IF LE Then Arriving "MyFunction"

Stage = 1000

' do some code

Stage = 1010

If TimeToQuit Then
   If LE Then Leaving ' always call before exit
   Exit Function
End if

Stage = 1020

If LE Then Leaving ' always call before exit

End Function

You can use an INI file switch to set LE = True if you require application debugging. The Arriving sub adds the sub name to a global stock of subs and Leaving reduces the stack by 1.  The advantage of this is tha you can call a global error handle which records all of the details of any errors and sends you an email.

HandleError "Stage:"+cstr(Stage)+ " - " + ErrDesc + " ~ "+SQL ' etc

0
 
Anthony PerkinsCommented:
You have to wonder, but than it is not like you were not warned. At least the questioner is consistent:

Questions Asked 9
Last 10 Grades Given B C C B B B C  
Question Grading Record 7 Answers Graded / 7 Answers Received

Anthony
0
 
rspahitzCommented:
sureshrao72, as you might guess, the surest way to fail to get responses from experts is to not participate in the discussion and then offer bad grades without explanation.

If you would like to correct the grade, please add a zero-point question in the customer support topic area and reference this, any, or all of your questions and ask that the grade be adjusted.

Meanwhile, good luck getting quality help from the experts at this site.  (It's not that you can't give lower grades, but they should always be explained as to why they are not "A"s.)
0
 
Anthony PerkinsCommented:
rspahitz,

What is so incredibly asinine about this is, is that it really only hurts the questioner, especially when no explanation is offered.

Anthony
0
 
sureshrao72Author Commented:
guys i dont really understand certain things in this site.

First, Im not able to close my question even if i accept an answer.

Second, im not able to increase my points, eventhough i closed all questions..by accepting an answer.

suresh
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.