![]() |
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 |
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 |
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 |
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 |
error 28: out of stack space call function
Thanks it is just to understand as i need to get data from function to
sub :) :) :) |
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 :) :) :) |
All times are GMT +1. The time now is 12:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com