I write this function
Public Function CheckWord(RTFName As RichTextBox)
.
.
.
.
end Function
when I call it from a form like this :
call CheckWord (RichTextBox1)
I got an error "Type mismatch" on the line in the form
what goes wrong ?
Thanks
Gil
Printable View
I write this function
Public Function CheckWord(RTFName As RichTextBox)
.
.
.
.
end Function
when I call it from a form like this :
call CheckWord (RichTextBox1)
I got an error "Type mismatch" on the line in the form
what goes wrong ?
Thanks
Gil
Sorry I forgot
When You call a function like this you need
to place the "call" word
Call CheckWord(RTFbox)
Is there some reason that you can't just pass RichTextBox1.Text? With a function name of CheckWord it doesn't seem that you would need to access any of the other properties.
If you must pass the control, do this:
Code:Public Function CheckWord(RTFName As Object)
Dim rtfn As RichTextBox
Set rtfn = RTFName
And I forgot to mention that you also have to type cast the function, i.e. Public Function CheckWord(RTFName As RichTextBox) As SOMETHING
Also, after looking into the matter, I realize that your original declaration (plus the cast) will work. I wrote a quick test with CheckWord returning the contents of RTFName.Text.
I tried leaving the "As String" off to see if it would cause the error. No error, but also no returned string. Maybe this will still give you something to try.Code:Private Sub Command1_Click()
Text1.Text = CheckWord(RichTextBox1)
End Sub
Private Function CheckWord(RTFName As RichTextBox) As String
CheckWord = RTFName.Text
End Function