Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks it is just to understand as i need to get data from function to
sub :) :) :) |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Out of Stack Space error | Excel Discussion (Misc queries) | |||
Out of Stack space - run time error 28 | Excel Discussion (Misc queries) | |||
'Out of stack space' error on SaveAs | Excel Programming | |||
Out of Stack Space error | Excel Programming | |||
Run time error 28: Out of stack space | Excel Programming |