From Xojo Documentation
|You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!|
Occurs when you try to assign a value to an object that is an incorrect data type.
A TypeMismatchException error occurs when you try to assign a value of an incorrect data type to an object. This error can occur only if the compiler cannot determine the type of the value at compile time - for example, when using variants. Ordinarily, the compiler catches incorrect typing when you try to compile the application.
The following code assigns a picture that has been added to the Project Editor to the variant, v, and then tries to assign v to an Integer. The Exception statement displays a message box, allowing the developer to track down the problem. Exception handling prevents the built application from quitting when the error occurs.
Var i As Integer
v = ProductLogo // a picture
i = v
If err IsA TypeMismatchException Then
MessageBox("The variable i must be assigned a number!")