user1527312
user1527312

Reputation: 779

VB Type Mismatch 'Return'

I want to use a function to return a string however, I keep getting a Type mismatch 'Return' error.

Any help would be much appreciated.

Dim myvar
myvar = getMultiLineString()
MsgBox(myvar)

Function getMultiLineString()

    Dim a(3)
    Dim i
    Dim query

    a(1)   = "test line 1"
    a(2)   = "test line 2"
    a(3)   = "test line 3"

    query = a(1)

    For i=2 to 3
        query = query & VbCrLf &  a(i)
    next

    MsgBox(query)
    Return query

End Function

Upvotes: 1

Views: 2237

Answers (1)

Gary_W
Gary_W

Reputation: 10360

Instead of

Return query

You would use "name_of_function = value_it_should_return":

getMultiLineString = query

Upvotes: 3

Related Questions