Run-time error:13 Type mismatch

Latexy

New Member
Joined
Oct 8, 2019
Messages
19
Hi.

I have this code in sub and its getting this run-time error for some reason. While debug it shows the value for change as "0" and value for textbox could be like "23.60"
If i change the variable as string it works but then calculations wont work.
VBA Code:
    Dim change As Double
    change = TextBoxChange.Value
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
What decimal separator is set in your regional settings?
 
Upvote 0
That's why it won't coerce to a number. Use Val:

Code:
change = Val(TextBoxChange.Value)
 
Upvote 0
Thanks for advice but i already tried that and it didn't give the error but the numeric value was far what it was supposed to be.
Like if the number was in textbox 12,5 the return of val was 43 597,00
 
Upvote 0
You indicated that the textbox had a full stop, not a comma in it. If your regional settings are using the same decimal separator as you are actually using in the textbox, use CDbl instead of Val.
 
Upvote 0
Thanks! That worked for that problem. I'm just learning this coding and trying to make one friend of mine a simple bookkeeping worksheet with form
 
Upvote 0
What exactly is in the textbox when it doesn't work?
 
Upvote 0
I try to tell you it as good as i know. So i have multiple textboxes and the textbox is given value from another textbox when user clicks button. when it gets the value from another textbox it should automatically calculate the current value with another textbox value for textbox showing value of those 2 textboxes.
 

Attachments

  • Sieppaa.PNG
    Sieppaa.PNG
    75.7 KB · Views: 5
Upvote 0

Forum statistics

Threads
1,214,848
Messages
6,121,914
Members
449,054
Latest member
luca142

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