Computer Science Canada Mario Puzzle panel: errors "System.InvalidCastException" |
Author: | MercerA [ Fri Jan 17, 2014 10:43 pm ] | ||||||
Post subject: | Mario Puzzle panel: errors "System.InvalidCastException" | ||||||
Hi. I'm making a copy of puzzle panel, a mini game from mario 64 ds. (https://www.youtube.com/watch?v=eDL-1AjquRA) I need help understanding why my code won't run properly. The program will run but when I try to click on one of the menu strip items that refer to the level, the program will stop and will highlight Dim picTileClicked As PictureBox = sender and tell me : "An unhandled exception of type 'System.InvalidCastException' occurred in puzzle panel.exe Additional information: Unable to cast object of type 'System.Windows.Forms.ToolStripMenuItem' to type 'System.Windows.Forms.PictureBox' Here I have displayed the procedures that use sender and e The beginning of my main event:
And this is one of the four sub functions that refer to that event
I don't know what's wrong with my code!?!!? Please help! I need this mark!!! I have attached the full copy of the code in a linked document below in case it is needed. https://docs.google.com/document/d/18ntWDHkYqa6hwjjXzyuCip5QD63-HCEllBhXSwxvdpg/edit?usp=sharing HELP ME. plz. thanks. Mod Edit: Please wrap you code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
|
Author: | Tony [ Sat Jan 18, 2014 12:02 am ] |
Post subject: | Re: Mario Puzzle panel: errors "System.InvalidCastException" |
MercerA @ Fri Jan 17, 2014 10:43 pm wrote: "An unhandled exception of type 'System.InvalidCastException' occurred in puzzle panel.exe
Additional information: Unable to cast object of type 'System.Windows.Forms.ToolStripMenuItem' to type 'System.Windows.Forms.PictureBox' The error message seems very clear: a ToolStripMenuItem is not a PictureBox, so you can't make the variable assignment that you are trying to do. |