id="info"

Question

Locked

Microsoft Visual Basic error: "expected: end of statement"

By Mobil-D ·
I'm experiencing an issue with macros in Word 2007. I copied the following code verbatim from MSDN (URL at bottom) into Microsoft Visual Basic: -

Public Function GetScreenTip(ByVal control As IRibbonControl) As String
Return "This is a screen tip for the menu."
End Function

However, I get a compiler error, "expected: end of statement", referring to the return statement. Now I'm no expert programmer, but from what I understand, it's pretty well commonplace for a function to return a value. I don't have much of a clue when it comes to VB though. Could anyone help me out?

http://msdn.microsoft.com/en-us/library/bb462634.aspx

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

No such thing as "return"

by Slayer_ In reply to Microsoft Visual Basic er ...

Public Function GetScreenTip(ByVal control As IRibbonControl) As String
GetScreenTip = "This is a screen tip for the menu."
End Function


Try that

Collapse -

Another error

by Mobil-D In reply to No such thing as "return"

Thanks for that, but now I get another error when I call the function, "Wrong number of arguments or invalid property assignment". Any ideas?

Collapse -

Resolved

by Mobil-D In reply to Another error

Just to say that I've resolved this issue, like so: -

Sub GetScreenTipcallback(control As IRibbonControl, ByRef screentip)

End Sub

Thanks again. :)

Collapse -

Bad code....

by Slayer_ In reply to Resolved

both using byref and using a variant are both bad coding practicies.


Sub GetScreenTipcallback(control As IRibbonControl, ByRef screentip)


Is the same as

Sub GetScreenTipcallback(ByRef control As IRibbonControl, ByRef screentip as variant)


It would be better to, if possible, specify byval for the second argument, and specify what type of value it is (sounds like a string)
So it would look like this
Sub GetScreenTipcallback(ByRef control As IRibbonControl, Byval sScreenTip as String)

Back to Software Forum
5 total posts (Page 1 of 1)  

Software Forums