|
-
Oct 5th, 2000, 10:05 AM
#1
Thread Starter
Junior Member
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
-
Oct 5th, 2000, 10:40 AM
#2
Thread Starter
Junior Member
Sorry I forgot
When You call a function like this you need
to place the "call" word
Call CheckWord(RTFbox)
-
Oct 5th, 2000, 10:43 AM
#3
Frenzied Member
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
-
Oct 5th, 2000, 11:02 AM
#4
Frenzied Member
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.
Code:
Private Sub Command1_Click()
Text1.Text = CheckWord(RichTextBox1)
End Sub
Private Function CheckWord(RTFName As RichTextBox) As String
CheckWord = RTFName.Text
End Function
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|