1

In a class module named, I have

Private pARRactivityPred() As String

Public Property Let predArray(Value() As String)
    pARRactivityPred = Value

End Property

And calling it:

record.predArray = Split(string1, ",")

However, i am not sure why i get the following error:

"Compile error: Definitions of property procedures for the same property are inconsistent, or property procedure has an optional parameter, a ParamArray, or an invalid set or final parameter"

Does anyone know whats going on?

1

1 Answer 1

1

This works:

Dim s() As String
s = Split("a,b,c,d", ",")
record.predArray = s

record.predArray expects a String array as input, but Split returns a Variant array, which causes a type mismatch error. Here I convert the output of Split to a String array and it works. This conversion can be done automatically using the assignment operator = as above, but it won't work through the input parameter of a procedure like predArray. The parameter has to be of the specific type specified in the procedure declaration: Value() As String.

I see that @mehow pressed the "answer" button a minute before I did :-) However I think that using a loop to convert from Variant array to String array like he does is unnecessarily long-winded.

However I am unable to reproduce your exact error. With your code I get a compile-time "type mismatch" error for the reasons outlined above -- not the error you describe.

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

Comments

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.