View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robert Crandal[_3_] Robert Crandal[_3_] is offline
external usenet poster
 
Posts: 161
Default ByRef argument type mismatch (repost)

I get a compile error, ByRef argument type mismatch,
with the following (streamlined) code. How can I fix this?

BTW, Gary, I have tried all variations of the TruncateString()
function that you posted. It still produces the same error.
Hopefully this simplified or stripped down code and help
narrow down the problem.

'--------------------------------------------------------------
Function TruncateString$(sText$, sFind$, Optional lStart& = 1)
TruncateString = Mid$(sText, lStart, InStr(sText, sFind) - lStart)
End Function
'--------------------------------------------------------------
Sub basicTest()
Dim s As String
Dim vData ' variant

s = "Hello world. Be the world. Goodnight world."
vData = Split(s, ".")

MsgBox TruncateString(vData(2), "world")

End Sub