"type mismatch" in the label caption

KhallP

Board Regular
Joined
Mar 30, 2021
Messages
157
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to perform a calculation in vba but when the program does it the error "Type mismatch" appears because the result is 0, can someone help me?

value_1.jpg




value_2.jpg





type_mismatch.jpg
 

Attachments

  • value_1.jpg
    value_1.jpg
    115.4 KB · Views: 31
If an empty textbox is not a valid input, you need to handle that in whatever manner is appropriate - eg treat it as 0, or flag it as an error to the user.
I really don't know what's going on, the account gave an amount that I don't know how it was calculated

capturar.JPG
 

Attachments

  • capturar.JPG
    capturar.JPG
    14 KB · Views: 7
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I don't know either. You have the workbook, so you'll have to step through the code to see what is happening
 
Upvote 0
If an empty textbox is not a valid input, you need to handle that in whatever manner is appropriate - eg treat it as 0, or flag it as an error to the user.
I tried to convert the variables, do you think this will work?

VBA Code:
   Y2_Axis_Orig_D = CInt(Y2_Axis_Orig_D)
        Z_550_Orig_D = CInt(Z_550_Orig_D)
 
Upvote 0
As long as the variable contains something that can be converted to an integer, yes.
 
Upvote 0
As long as the variable contains something that can be converted to an integer, yes.
how can i do the reverse? in this case pass an integer variable to a "variant" variable
 
Upvote 0
Just assign it to the variable. A Variant can contain anything.
 
Upvote 0
Let me explain, I have a module that contains public variables and on a specific Form I assign a value to that variable that is specified as integer in the module, but later on in another form I need to pass these variables to "variant" how can I do this ?
Just assign it to the variable. A Variant can contain anything.
 
Upvote 0
As I said - just assign it:

Code:
myVariant = myInteger

for example.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top