I'm getting a compiler error from a function call and I can't see why. I'm looping through an array of strings and passing the current string to a function.
Code:
Dim song_title, song_quote As String
For Each Item In song_list ' song list is an array of strings
song_title = Item
song_quote = ""
song_quote = getSubSection(Item, "[", "]") ' COMPILER ERROR!! "ByRef argument type mismatch"
Next
The function itself, which returns a string is declared in this form:
Code:
Function getSubSection(SingleComposition As String, start_char As String, end_char As String)
I tried passing the string variable instead of Item, but got the same error:
Code:
song_quote = getSubSection(song_title, "[", "]")
I find that if I pass '"" & Item' as the argument the compiler doesn't complain, but I don't understand why it's necessary. If I'm passing a string, why do I need to add code to convince the compiler that it's a string?
Code:
song_quote = getSubSection("" & Item, "[", "]")