0

I am working on a simple tool that will allow me to parse multiple CSV files and spit them out onto a fresh worksheet "merged" together. Here is my implementation (I've simplified it) and my issue:

Class A

private variables as types
property methods for accessing variables

Class B

private variables as types
property methods for accessing variables

Class C

Private cA as ClassA
Private cB as Collection  'Collection of ClassB

Class D - Part of my problem

Private cC as Collection 'Collection of ClassC
'Other member variables and their property get/lets

Public Sub AddA(A as ClassA)
    If cC.Item(A.foo) is Nothing then 
        dim tempC as ClassC
        set tempC = new ClassC
        tempC.A = A
    End if
End Sub

Main Module - Other half of my problem

Dim cC as New ClassC
'Initialize Class C, this all works fine
Dim tempA as ClassA
Set tempA = new ClassA
'Set tempA properties
cC.AddA tempA  'This is where my error is

I've tried passing it as ByVal and ByRef each gives me different errors ("byref argument type mismatch", "invalid procedure or argument", and "Object doesn't support this property or method"

I have no idea what to try next, I even tried the parenthesis "thing" that supposedly forces the parameter into either ByVal or ByRef, I can't remember, that was yesterday.

Thanks.

4
  • The error is inside AddA, so some code would help. I'd also bet you want Public Sub AddA(ByVal A as ClassA). Commented May 11, 2011 at 14:25
  • @GSerg I receive the error in the main module calling the sub, and I've tried using ByVal A as ClassA, I get the "Invalid procedure or argument" error. Please note I added the code for AddA, and realised at the same time I completely left out a class. I've completely updated all the code. Sorry about that. Commented May 11, 2011 at 15:21
  • Play with Tools -> Options -> General -> Error Trapping to change where you see the error. In this case you might want "Break in class module." Commented May 11, 2011 at 15:28
  • @GSerg Ok, now I see where the error is actually occurring, and it seems to be where I preform my check If cC.Item(A.Foo) is Nothing then, according to the docs if the item doesn't exist, it will simply error instead of returning a nothing value. Let me fix this, then we'll see what happens Commented May 11, 2011 at 15:38

1 Answer 1

0

This line:

tempC.A = A 

means "assing to A property of tempC object the value of the default property of the A object."
Your A object apparently doesn't have a default property.

What you actually meant was probably:

Set tempC.A = A 

But even then, you can't access a private field A of C class from D class. Make the field public or create a public SetA() method on C class and call it from D.

Sign up to request clarification or add additional context in comments.

1 Comment

This didn't actually solve my problem, it was actually somewhere else in my code, but you set me looking on the right path, and I didn't know about the Error Trapping settings (which helped a ton), so I'm going to mark this as the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.