+ Reply to Thread
Results 1 to 6 of 6

error 28: out of stack space call function

  1. #1
    ina
    Guest

    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. #2
    Tom Ogilvy
    Guest

    RE: 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. #3
    Dana DeLouis
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #4
    Tim Williams
    Guest

    Re: 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" <[email protected]> wrote in message news:[email protected]...
    > 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. #5
    ina
    Guest

    Re: 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. #6
    Tom Ogilvy
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1