Out Of Stack error... again... :-( Please help me! 
Author Message
 Out Of Stack error... again... :-( Please help me!

Hello Everybody!
I'm pratically going insane with the Out of Stack Error (error 28).
I've tried everything and i have come to no conclusion, so i must ask for
your help as my last hope... :-(
The basic idea is:
In form i have textbox (nbxSP()) that accepts F12 keypress and runs the
"DO_SEARCH" sub.
This Sub loads and shows modaly another form were are i show some registers
from a DAtabase table (SQL 2000) in a DATAGRID CONTROL.
The class "clsBUSCA" is responsable for perfoming the "select operations"
over the DataBase.
So far so good? I think it's trivial so far...

The error triggers in the line "***     vForm.Show vbModal".
Through F8 steps i found out that the error begans in the line "*** UNLOAD
ME" (on the form showed modaly).

I've tried to catch empredicdable "key events" in the forms with msgboxs...
but i found nothing!
No abnormal situation in the CALL STACK window (only 3 lines), no recursive
code (at least no visible one)...
No fixed-length strings declared, etc...

i'm beginning to think that the problem is associataded with the datagrid,
but once more i don't know why...

Any Thoughts? Ideas???
If anyone is interested to go more into this e-mail me that i'll send the
forms with all the code...
If anyone has any clue of what is happening, please, pretty please.... help
me!

Here's the code...
Thanks...

---------------------------------------- CODE
SAMPLES -------------------------------
Private Sub nbxSP_KeyDown(Index As Integer, KeyCode As Integer, Shift As
Integer)
Static rsGeT As ADODB.Recordset
    Select Case KeyCode
    Case vbKeyF12
        If Index < 2 Then DO_SEARCH cTabLE, Trim(nbxSP(0).Text),
Trim(nbxSP(1).Text)
    Case vbKeyReturn
        Select Case Index
        Case 0
            nbxSP(1).SetFocus
        Case 1
            nbxSP(2).SetFocus
        Case 2
            grdSP(1).SetFocus
        End Select
    Case vbKeyEscape
     Unload Me
    End Select
End Sub

Private Static Sub DO_SEARCH(kTab As String, kID As String, kDesc As String)
Static resp As Long
Static vForm As Form
    Set buscaCLS = New clsBuscas
    resp = buscaCLS.FindRecords(kTab, kID, kDesc)
    If resp = vbYes Then
        Set vForm = New frmResults
        Load vForm
        vForm.vFormSource = Me.Name

***     vForm.Show vbModal

    End If
    If buscaCLS.Encontrou Then
        nbxSP(0).Text = buscaCLS.ID
        nbxSP(1).Text = buscaCLS.Descricao
        nbxSP(2).SetFocus
    End If
    Set vForm = Nothing
    Set buscaCLS = Nothing
End Sub

--------------------- double click in the datagrid causes the
error....------------

Private Sub grdResults_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        JaEncontrei

*** UNLOAD ME

    ElseIf KeyAscii = vbKeyEscape Then
        Unload Me
    End If
End Sub

ASS:MIGAS



Thu, 22 Jul 2004 06:25:06 GMT  
 Out Of Stack error... again... :-( Please help me!
Of course, no one can test without the full source so.. the only thing I can
suggest is to generously sprinkle Debug.Print's around (you've already done
that?) and place a break point on every "Unload Me" and single step from
there. Make sure the same Debug.Print's are showing whether single stepped
or running full speed.

A couple suggestions though... make that static variable module level
scope.. Static variables are stored on the stack..

Quote:
> Private Sub nbxSP_KeyDown(Index As Integer, KeyCode As Integer, Shift As
> Integer)
> Static rsGeT As ADODB.Recordset

These static's can be changed to "Dim's" because you're not using them as
statics (that is, you're not testing their values before setting them to new
values)
Also, you may want to change that "As Form" to "As frmResults".. at least,
you'll get intellisense to show the publics in that form.

Quote:
> Private Static Sub DO_SEARCH(kTab As String, kID As String, kDesc As
String)
> Static resp As Long
> Static vForm As Form

Here's another thing you may want to do.. Get rid of the "Load vForm"..
Form_Load will fire on its own when you "Show" it and explicitly loading it
may cause effects you're not looking for because this changes the "natural"
order that the events will be fired.

Quote:
>         Set vForm = New frmResults
>         Load vForm
>         vForm.vFormSource = Me.Name

> ***     vForm.Show vbModal

This demonstrates a good use for statics.. if you paste this into a new
project with a textbox and leave the code as is, you'll get an Out of Stack
space error the first time you change the contents of the box.. Remove the
comments and the code runs only once. If you add this type of test to your
problem code, the problem may go away..
'==========
Private Sub Text1_Change()
   Static bHere As Boolean
   'If Not bHere Then
      'bHere = True
      Debug.Print "Text1_Change", Timer
      Text1.Text = "Test" & 10 * Rnd
      'bHere = False
   'End If
End Sub
'==========

--
Ken Halter
MS-MVP-VB
Please keep it in the groups..


Quote:
> Hello Everybody!
> I'm pratically going insane with the Out of Stack Error (error 28).
<SNIP>
> ASS:MIGAS



Thu, 22 Jul 2004 07:12:10 GMT  
 Out Of Stack error... again... :-( Please help me!
From MS web site.

The stack is a working area of memory that grows and shrinks dynamically
with the demands of your executing program. This error has the following
causes and solutions:

  a.. You have too many active Function, Sub, or Property procedure calls.
  Check that procedures aren't nested too deeply. This is especially true
with recursive procedures, that is, procedures that call themselves. Make
sure recursive procedures terminate properly. Use the Calls dialog box to
view which procedures are active (on the stack).

  b.. Your local variables require more local variable space than is
available.
  Try declaring some variables at the module level instead. You can also
declare all variables in the procedure static by preceding the Property,
Sub, or Function keyword with Static. Or you can use the Static statement to
declare individual Static variables within procedures.

  c.. You have too many fixed-length strings.
  Fixed-length strings in a procedure are more quickly accessed, but use
more stack space than variable-length strings, because the string data
itself is placed on the stack. Try redefining some of your fixed-length
strings as variable-length strings. When you declare variable-length strings
in a procedure, only the string descriptor (not the data itself) is placed
on the stack. You can also define the string at module level where it
requires no stack space. Variables declared at module level are Public by
default, so the string is visible to all procedures in the module.

  d.. You have too many nested DoEvents function calls.
  Use the Calls dialog box to view which procedures are active on the stack.

  e.. Your code triggered an event cascade.
  An event cascade is caused by triggering an event that calls an event
procedure that's already on the stack. An event cascade is similar to an
unterminated recursive procedure call, but it's less obvious, since the call
is made by Visual Basic rather than by an explicit call in your code. Use
the Calls dialog box to view which procedures are active (on the stack).

To display the Calls dialog box, select the Calls button to the right of the
Procedure box in the Debug window or choose the Calls command. For
additional information, select the item in question and press F1.


Quote:
> Hello Everybody!
> I'm pratically going insane with the Out of Stack Error (error 28).
> I've tried everything and i have come to no conclusion, so i must ask for
> your help as my last hope... :-(
> The basic idea is:
> In form i have textbox (nbxSP()) that accepts F12 keypress and runs the
> "DO_SEARCH" sub.
> This Sub loads and shows modaly another form were are i show some
registers
> from a DAtabase table (SQL 2000) in a DATAGRID CONTROL.
> The class "clsBUSCA" is responsable for perfoming the "select operations"
> over the DataBase.
> So far so good? I think it's trivial so far...

> The error triggers in the line "***     vForm.Show vbModal".
> Through F8 steps i found out that the error begans in the line "*** UNLOAD
> ME" (on the form showed modaly).

> I've tried to catch empredicdable "key events" in the forms with
msgboxs...
> but i found nothing!
> No abnormal situation in the CALL STACK window (only 3 lines), no
recursive
> code (at least no visible one)...
> No fixed-length strings declared, etc...

> i'm beginning to think that the problem is associataded with the datagrid,
> but once more i don't know why...

> Any Thoughts? Ideas???
> If anyone is interested to go more into this e-mail me that i'll send the
> forms with all the code...
> If anyone has any clue of what is happening, please, pretty please....
help
> me!

> Here's the code...
> Thanks...

> ---------------------------------------- CODE
> SAMPLES -------------------------------
> Private Sub nbxSP_KeyDown(Index As Integer, KeyCode As Integer, Shift As
> Integer)
> Static rsGeT As ADODB.Recordset
>     Select Case KeyCode
>     Case vbKeyF12
>         If Index < 2 Then DO_SEARCH cTabLE, Trim(nbxSP(0).Text),
> Trim(nbxSP(1).Text)
>     Case vbKeyReturn
>         Select Case Index
>         Case 0
>             nbxSP(1).SetFocus
>         Case 1
>             nbxSP(2).SetFocus
>         Case 2
>             grdSP(1).SetFocus
>         End Select
>     Case vbKeyEscape
>      Unload Me
>     End Select
> End Sub

> Private Static Sub DO_SEARCH(kTab As String, kID As String, kDesc As
String)
> Static resp As Long
> Static vForm As Form
>     Set buscaCLS = New clsBuscas
>     resp = buscaCLS.FindRecords(kTab, kID, kDesc)
>     If resp = vbYes Then
>         Set vForm = New frmResults
>         Load vForm
>         vForm.vFormSource = Me.Name

> ***     vForm.Show vbModal

>     End If
>     If buscaCLS.Encontrou Then
>         nbxSP(0).Text = buscaCLS.ID
>         nbxSP(1).Text = buscaCLS.Descricao
>         nbxSP(2).SetFocus
>     End If
>     Set vForm = Nothing
>     Set buscaCLS = Nothing
> End Sub

> --------------------- double click in the datagrid causes the
> error....------------

> Private Sub grdResults_KeyPress(KeyAscii As Integer)
>     If KeyAscii = vbKeyReturn Then
>         JaEncontrei

> *** UNLOAD ME

>     ElseIf KeyAscii = vbKeyEscape Then
>         Unload Me
>     End If
> End Sub

> ASS:MIGAS



Thu, 22 Jul 2004 07:21:22 GMT  
 Out Of Stack error... again... :-( Please help me!
Quote:
> scope.. Static variables are stored on the stack..

Ooops.. crossed signals in the brain.. Local variables are stored on the
stack.. not statics..

--
Ken Halter
MS-MVP-VB
Please keep it in the groups..


Quote:
> Of course, no one can test without the full source so.. the only thing I
can
> suggest is to generously sprinkle Debug.Print's around (you've already
done
> that?) and place a break point on every "Unload Me" and single step from
> there. Make sure the same Debug.Print's are showing whether single stepped
> or running full speed.

> A couple suggestions though... make that static variable module level
> scope.. Static variables are stored on the stack..
> > Private Sub nbxSP_KeyDown(Index As Integer, KeyCode As Integer, Shift As
> > Integer)
> > Static rsGeT As ADODB.Recordset

> These static's can be changed to "Dim's" because you're not using them as
> statics (that is, you're not testing their values before setting them to
new
> values)
> Also, you may want to change that "As Form" to "As frmResults".. at least,
> you'll get intellisense to show the publics in that form.
> > Private Static Sub DO_SEARCH(kTab As String, kID As String, kDesc As
> String)
> > Static resp As Long
> > Static vForm As Form

> Here's another thing you may want to do.. Get rid of the "Load vForm"..
> Form_Load will fire on its own when you "Show" it and explicitly loading
it
> may cause effects you're not looking for because this changes the
"natural"
> order that the events will be fired.
> >         Set vForm = New frmResults
> >         Load vForm
> >         vForm.vFormSource = Me.Name

> > ***     vForm.Show vbModal

> This demonstrates a good use for statics.. if you paste this into a new
> project with a textbox and leave the code as is, you'll get an Out of
Stack
> space error the first time you change the contents of the box.. Remove the
> comments and the code runs only once. If you add this type of test to your
> problem code, the problem may go away..
> '==========
> Private Sub Text1_Change()
>    Static bHere As Boolean
>    'If Not bHere Then
>       'bHere = True
>       Debug.Print "Text1_Change", Timer
>       Text1.Text = "Test" & 10 * Rnd
>       'bHere = False
>    'End If
> End Sub
> '==========

> --
> Ken Halter
> MS-MVP-VB
> Please keep it in the groups..



> > Hello Everybody!
> > I'm pratically going insane with the Out of Stack Error (error 28).
> <SNIP>
> > ASS:MIGAS



Thu, 22 Jul 2004 08:11:57 GMT  
 Out Of Stack error... again... :-( Please help me!

Quote:
> Hello Everybody!
> I'm pratically going insane with the Out of Stack Error (error 28).
> I've tried everything and i have come to no conclusion, so i must ask for
> your help as my last hope... :-(
> The basic idea is:
> In form i have textbox (nbxSP()) that accepts F12 keypress and runs the
> "DO_SEARCH" sub.
> This Sub loads and shows modaly another form were are i show some
registers
> from a DAtabase table (SQL 2000) in a DATAGRID CONTROL.
> The class "clsBUSCA" is responsable for perfoming the "select operations"
> over the DataBase.
> So far so good? I think it's trivial so far...

My last happy experience with the out of stack call was due to one of the
property procedures in one of my classes.

Private lPropName as Long
...
Public Property Let PropName(byval lNewValue as Long)
    PropName = lNewValue      (should have been lPropName = lNewValue)
End Property

I've done thousands of simple property statements like these in my objects,
but I just brainfarted on this one.  It wasn't showing up in the call stack,
either.  Not only that, I was getting the Stack Error in an almost totally
unrelated part of the program, so it was a real stinker to find.

Anyway, look away from where you are looking now.  And try stepping through
the code with the de{*filter*}.  I had to look through 4 project files to find
this one, going one line at a time for probably about a half hour.

--
We find that the history of the Second Amendment reinforces the plain
meaning of its text, namely that it protects individual Americans in their
right to keep and bear arms whether or not they are a member of a select
militia or performing active military service or training.
-US 5th Circuit Court of Appeals, USA v. Emerson 99-10331 10/16/01



Fri, 23 Jul 2004 23:20:50 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Please help with Out of Stack Space error

2. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

3. help again please:error msg doesn't work

4. Out Of Stack error... again... :-( Please help me!

5. Out Of Stack error... again... :-( Please help me!

6. Out Of Stack error... again... :-( Please help me!

7. Error in VBA6.DLL\MSVBVM60.DLL, please reboot and try again

8. Need help with time outs

9. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

10. HELP: Avoiding "out of stack" errors

11. Troy Can you help me again Please

12. UDP again - please help ms!

 

 
Powered by phpBB® Forum Software