Signature does not match expected signature

ChrShe

Member
Licensed User
Longtime User
Hi all!

I'm getting this error when trying to add a click even to a dynamically generated panel.

Here is (basically) what I'm doing...only adding snippet because I'm more interested in what the error means:
B4X:
...
pnl.Initialize("dPanel")
...
Sub dPanel_Click(pnl as Object)
   Dim p as Panel
   p = pnl
   Msgbox(p.Tag, "FOO")
End Sub
When I tap on the panel, I get an error message saying:
"An error has occurred in the sub: dpanel_click signature does not match expected signature. Continue?"

Thanks!!!
Chris
 

stevel05

Expert
Licensed User
Longtime User
The error means that the subroutine definition Sub dPanel_Click(pnl as Object) is not formed correctly.

The panel _click subroutine does not expect any arguments to be returned. So it's signature should be

Sub dPanel_Click

.
.
.
End sub

If you want to get the panel object when clicked, it is provided by the sender object;


Sub dPanel_Click

Dim P As Panel

P = Sender
.
.
.
End sub

If you type Sub and then a space in the IDE it prompts you to press tab to insert the event declaration, press tab and you get a list of objects select one and press enter and it lists the declarations and their required formats. Select one of these and it will insert the correct signature for you.
 
Last edited:
Upvote 0

ChrShe

Member
Licensed User
Longtime User
If you type Sub and then a space in the IDE it prompts you to press tab to insert the event declaration, press tab and you get a list of objects select one and press enter and it lists the declarations and their required formats. Select one of these and it will insert the correct signature for you.

Weird...I'm not seeing that behaviour.
I'll have to do some digging...maybe I have an IDE setting incorrect.

Thanks for the help!!!
:)
Chris
 
Upvote 0

dagnabitboy

Active Member
Licensed User
Longtime User
If you type Sub and then a space in the IDE it prompts you to press tab to insert the event declaration, press tab and you get a list of objects select one and press enter and it lists the declarations and their required formats. Select one of these and it will insert the correct signature for you.

Hah! I wished I'd found that little gem before now!! Thanks for posting that. By the way, works great here.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It doesn't work in a Code Module as you cannot capture events there, but it should work in Activity modules.

I seem to remember reading a post that said it wouldn't prompt under certain circumstances, I think it was to do with malformed subs or loops, but I can't find the post and cant get the prompt to not work.

If you're still having trouble, try it in a new project just to see.

Steve
 
Upvote 0

ChrShe

Member
Licensed User
Longtime User
Ah...looks like I was doing it wrong/typing too fast/not paying attention... :signOops:

It's working fine and will be super helpful and time-saving. :)

Thanks.
Chris
 
Upvote 0
Top