Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Run-time error '28': Out of stack space

Posted on 2009-07-07
4
Medium Priority
?
265 Views
Last Modified: 2012-05-07
This line...

clsVendor.Name = sVendor

...produces this error...

Run-time error '28': Out of stack space

I've highlighted the offending line with a box of ***. Does anyone know what is causing this error?
'Code in worksheet module:
 
Private Sub CommandButton1_Click()
    
    Dim wkb1 As Workbook, wkb2 As Workbook
    Dim lRowCounter As Long, lColumnCounter As Long
    Dim sFullName1 As String, sFileName1 As String, sFullName2 As String, sFileName2 As String
    Dim sVendor As String
    Dim dTotalCost As Double, dTotalSales As Double
 
    'sFullName1 = "\\msfs05.lowes.com\DATA1\SHARE\Lognet\Channel Change Process\13. IP&E Planning\Templates\Template ProForma Comp\JBK Examples\Data Collection Fields_v13 Routine.xls"
    sFullName1 = "C:\Documents and Settings\dpark\Desktop\Data Collection Fields_v13 Routine.xls"
    sFileName1 = sGetFileName(sFullName1)
    
    'sFullName2 = "\\msfs05.lowes.com\DATA1\SHARE\Lognet\Channel Change Process\13. IP&E Planning\Templates\Template ProForma Comp\JBK Examples\2009 L&G Fall Equipment_Program Sheet.xls"
    sFullName2 = "C:\Documents and Settings\dpark\Desktop\2009 L&G Fall Equipment_Program Sheet.xls"
    sFileName2 = sGetFileName(sFullName2)
      
    'Make sure both workbooks open
    If bIsWorkbookOpen(sFileName1) Then
        Set wkb1 = Workbooks(sFileName1)
        wkb1.Activate
    Else
        Set wkb1 = Workbooks.Open(Filename:=sFullName1)
        wkb1.Activate
    End If
        
    If bIsWorkbookOpen(sFileName2) Then
        Set wkb2 = Workbooks(sFileName2)
    Else
        Set wkb2 = Workbooks.Open(Filename:=sFullName2)
    End If
    
'    Dim mcolVendors As New Collection
    
    lRowCounter = 20
    lColumnCounter = 2
    
    With wkb2.Worksheets("2009")
        Do Until IsEmpty(.Cells(lRowCounter, "B"))
            sVendor = .Cells(lRowCounter, "B").Value
            
            AddVendor sVendor, lRowCounter
            If mcolVendors(sVendor) Is Nothing Then
                AddVendor sVendor, lRowCounter
            End If
                        
            mcolVendors(sVendor).TotalCost = mcolVendors(sVendor).TotalCost + .Cells(lRowCounter, "N").Value
            mcolVendors(sVendor).TotalSales = mcolVendors(sVendor).TotalSales + .Cells(lRowCounter, "O").Value
        Loop
    End With
End Sub
 
'Code in standard module:
 
Sub AddVendor(sVendor As String, lRowCounter As Long)
    Dim clsVendor As CVendor
    With Workbooks("2009 L&G Fall Equipment_Program Sheet.xls").Worksheets("2009")
        Set clsVendor = New CVendor
***********************************************
**      clsVendor.Name = sVendor      **
***********************************************
        mcolVendors.Add clsVendor, sVendor
    End With
End Sub
 
'Code in class module
 
Private dSumCost As Double
Private dSumSales As Double
 
Property Let Name(sVendor)
    Name = sVendor
End Property
 
'Sum TotalCost values
Property Let TotalCost(dTotalCost As Double)
    TotalCost = TotalCost + dTotalCost
End Property
 
'Sum TotalSales values
Property Let TotalSales(dTotalSales As Double)
    TotalSales = TotalSales + dTotalSales
End Property
 
'Return TotalCost
Property Get TotalCost() As Double
    TotalCost = TotalCost
End Property
 
'Return TotalSales
Property Get TotalSales() As Double
    TotalSales = TotalSales
End Property
 
Public Function PercentMargin() As Double
    GetPercentMargin = (TotalSales1 - TotalCost1) / TotalSales1
End Function

Open in new window

0
Comment
Question by:ltdanp22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:ltdanp22
ID: 24796509
Additional Info:

The code enters and then re-runs this line until the Out of stack space error pops up...

Property Let Name(sVendor)
    Name = sVendor
End Property

Is Name a reserved word?
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 24796521
I think that we need to know more about what CVendor is. However, you should be aware that Out-of-stack space errors are usually caused by a runaway recursion loop.
0
 

Author Closing Comment

by:ltdanp22
ID: 31600715
syntax of property let was wrong. need to instantiate private variables and set them equal to argument
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24797494
Property Let Name(sVendor)
    Name = sVendor
End Property

means that on this line:
Name = sVendor

you call the property let method again... and again ... and again...

instead, it should assign to a class -level variable




private _Name as string 
Public Property Let Name(sVendor as string)
    _Name = sVendor
End Property 
Public Property Get Name as string
    Name = _Name
End Property

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question