I've created a collection in a class, now want to return it via a property in the class.
The invocation (below) to return the class is giving me "Compile Error Argument not optional"
There are no arguments- why is the compiler complaining?
The AllTestNames collection is defined in another class as followsCode:Sub CreateLabReport() Dim filereader As New clsReadTextFile Dim AllTestNames As New Collection AllTestNames = filereader.getAllTestNames() ' this line causes error msg end sub
Code:Private colAlltests As New Collection Property Get getAllTestNames() As Collection getAllTestNames = colAlltests End Property Private Sub Class_Initialize() testNamesMasterList = "testnames.txt" Call ReadTestNames End Sub Private Sub SeparateTestnames(listofTests As String) Dim newtest As clsTestDescription Dim teststr() As String Dim x, lastTestNum As Integer Dim testNumber As Long teststr() = Split(listofTests, vbCrLf) lastTestNum = UBound(teststr) testNumber = 1 ' these are arbitrary test numbers For x = 0 To lastTestNum 'If teststr(x) <> "" Then If LenB(teststr(x)) <> 0 Then ' don't add to collection, if string is empty Set newtest = New clsTestDescription newtest.letTestname = Trim(teststr(x)) newtest.letTestNumber = testNumber ' arbitrary test number colAlltests.Add newtest testNumber = testNumber + 1 End If Next x End Sub




Reply With Quote