nhorton79
Registered User.
- Local time
- , 11:20
- Joined
- Aug 17, 2015
- Messages
- 149
Hi All,
I have a class 'LineItem':
	
	
	
		
Then I have another class called 'Invoice'
	
	
	
		
I'm trying to create an instance of an Invoice and then create multiple instances of LineItem and store them in the LineItems dictionary.
I'm testing in a Public Sub:
	
	
	
		
I keep getting error "Argument is not optional" on the line:
	
	
	
		
I've tried changing declaration of the m_LineItems as many different types, but cannot seem to get this to work, and would really appreciate any assistance.
 I have a class 'LineItem':
		Code:
	
	
	Option Explicit
' Member variables
Private m_LineItemID As String
Private m_Description As String
Private m_Quantity As Double
Private m_UnitAmount As Double
Private m_AccountCode As String
Private m_TaxType As String
' Properties
Property Get LineItemID() As String
    LineItemID = m_LineItemID
End Property
Property Let LineItemID(value As String)
    m_LineItemID = value
End Property
Property Get Description() As String
    Description = m_Description
End Property
Property Let Description(value As String)
    m_Description = value
End Property
'...Balance of Property declarations for other member variables
Property Get TaxType() As String
    TaxType = m_TaxType
End Property
Property Let TaxType(value As String)
    m_TaxType = value
End Property
' Methods
Public Sub Init(Description As String)
    Me.Description = Description
End SubThen I have another class called 'Invoice'
		Code:
	
	
	Option Explicit
' Member variables
Private m_InvoiceID As String
Private m_InvoiceNumber As String
Private m_Reference As String
Private m_ContactID As String
Private m_InvoiceDate As Date
Private m_DueDate As Date
Private m_BrandingTheme As String
Private m_LineItems As Dictionary
' Properties
Property Get InvoiceID() As String
    InvoiceID = m_InvoiceID
End Property
Property Let InvoiceID(value As String)
    m_InvoiceID = value
End Property
Property Get InvoiceNumber() As String
    InvoiceNumber = m_InvoiceNumber
End Property
Property Let InvoiceNumber(value As String)
    m_InvoiceNumber = value
End Property
'...Balance of Property declarations for other member variables
Property Get BrandingTheme() As String
    BrandingTheme = m_BrandingTheme
End Property
Property Let BrandingTheme(value As String)
    m_BrandingTheme = value
End Property
Property Get LineItems(key As Integer) As LineItem
    Set LineItems(key) = m_LineItems(key)
End Property
Property Set LineItems(key As Integer, value As LineItem)
    m_LineItems.Add key, value
End Property
' Methods
Public Sub Class_Initialize()
    Set m_LineItems = New Dictionary
End Sub
Public Sub Init(ContactID As String, InvoiceNumber As String, Reference As String, InvoiceDate As Date, DueDate As Date)
    Me.ContactID = ContactID
    Me.InvoiceNumber = InvoiceNumber
    Me.Reference = Reference
    Me.InvoiceDate = InvoiceDate
    Me.DueDate = DueDate
    Me.BrandingTheme = BrandingTheme
End SubI'm trying to create an instance of an Invoice and then create multiple instances of LineItem and store them in the LineItems dictionary.
I'm testing in a Public Sub:
		Code:
	
	
	Public Sub InvoiceTest()
Dim INV As New Invoice
Dim LI1 As New LineItem
LI1.Init "Design, produce and install building signage to the new premises as requested by John"
LI1.Quantity = 1
LI1.UnitAmount = 2250
INV.Init "", "39799", "John", #8/10/2020#, #10/30/2020#
INV.LineItems.Add 1, LI1
End SubI keep getting error "Argument is not optional" on the line:
		Code:
	
	
	INV.LineItems.Add 1, LI1I've tried changing declaration of the m_LineItems as many different types, but cannot seem to get this to work, and would really appreciate any assistance.
 
	 
 
		 
 
		 
 
		 
 
		