Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default error 28: out of stack space call function

Hello guys,

I am newbie in VBA and I have an error 28: out of stack space; I do not
understand why :(

Sub test1()

Dim cenom, cenonlala As String

cenom = test2(cenonlala) ' I get this string name to input in my
query

End Sub


Function test2(cenomtras As String) As String 'this function give me a
string name

cenonlala = "LALA"

test2 = test2("LALA")

End Function


Can someone help me?

Ina

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default error 28: out of stack space call function

Right here, you call test2 from within test2

Function test2(cenomtras As String) As String 'this function give me a
string name

cenonlala = "LALA"

' recursive call here
test2 = test2("LALA")

End Function

Since you don't have any terminating logic in the Function, it continues to
call itself until it runs out of stack space.

--
Regards,
Tom Ogilvy



"ina" wrote:

Hello guys,

I am newbie in VBA and I have an error 28: out of stack space; I do not
understand why :(

Sub test1()

Dim cenom, cenonlala As String

cenom = test2(cenonlala) ' I get this string name to input in my
query

End Sub


Function test2(cenomtras As String) As String 'this function give me a
string name

cenonlala = "LALA"

test2 = test2("LALA")

End Function


Can someone help me?

Ina


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default error 28: out of stack space call function

I am newbie in VBA and I have an error 28: out of stack space; I do not
understand why :(


Hi. Here's a technique to understand why.
Put your cursor somewhere within sub "test1" and hit the F8 key over and
over to follow the code.
This will step you thru your code. When you get to Test2, you will see that
the code calls Test2 over and over again. Vba eventually runs out of a
designated storage area (a 'stack' ) to keep track of each call.

I think in earlier versions the limit was about 2000+ calls, but in Excel
2003, it looks like it was increased to about 5000+ calls.

This is just a wild guess at your code...

Sub Test3()
Dim cenom As String
cenom = Test4
End Sub


Function Test4()
Const cenonlala As String = "LALA"
Test4 = cenonlala
End Function

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"ina" wrote in message
oups.com...
Hello guys,

I am newbie in VBA and I have an error 28: out of stack space; I do not
understand why :(

Sub test1()

Dim cenom, cenonlala As String

cenom = test2(cenonlala) ' I get this string name to input in my
query

End Sub


Function test2(cenomtras As String) As String 'this function give me a
string name

cenonlala = "LALA"

test2 = test2("LALA")

End Function


Can someone help me?

Ina



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default error 28: out of stack space call function

test2 calls itself in an endless loop: that is probably not what you meant to do.

What should your code be doing?

--
Tim Williams
Palo Alto, CA


"ina" wrote in message oups.com...
Hello guys,

I am newbie in VBA and I have an error 28: out of stack space; I do not
understand why :(

Sub test1()

Dim cenom, cenonlala As String

cenom = test2(cenonlala) ' I get this string name to input in my
query

End Sub


Function test2(cenomtras As String) As String 'this function give me a
string name

cenonlala = "LALA"

test2 = test2("LALA")

End Function


Can someone help me?

Ina



  #5   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default error 28: out of stack space call function

Thanks it is just to understand as i need to get data from function to
sub

:) :) :)



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default error 28: out of stack space call function

Just assign the value to return to the name of the function:

Sub test1()

Dim cenom, cenonlala As String

cenom = test2(cenonlala)
End Sub


Function test2(cenomtras As String) As String

cenonlala = "LALA"

test2 = cenonlala

End Function

--
Regards,
Tom Ogilvy


"ina" wrote:

Thanks it is just to understand as i need to get data from function to
sub

:) :) :)


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Out of Stack Space error TheMilkGuy Excel Discussion (Misc queries) 2 July 22nd 09 05:54 PM
Out of Stack space - run time error 28 Rob Excel Discussion (Misc queries) 2 December 17th 07 04:55 PM
'Out of stack space' error on SaveAs Tim[_45_] Excel Programming 3 September 22nd 05 05:51 PM
Out of Stack Space error JimFor Excel Programming 2 December 26th 04 08:41 PM
Run time error 28: Out of stack space Will Wirtz Excel Programming 1 April 27th 04 01:39 PM


All times are GMT +1. The time now is 11:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"