vba textbox format number problem

paroduso

Board Regular
Joined
Sep 11, 2013
Messages
103
Office Version
  1. 2019
Platform
  1. Windows
hi everyone...
im having trouble formating a number inside 2 textboxes..
i allready tried a lot of codes...searching in google...but none worked for me...
well its textboxes resulting from a multiplication

teste.jpg


how can i format the textboxes to 4 decimal places??? i need the result to be 0.2621 in the textbox1 and 0.2482 textbox.2

thank you.
 
If you are getting a comma instead of a dot, that is because your decimal point is set to be a comma. I don't do programming for locales other than the U.S., so I cannot test this, but I am thinking simply replacing the comma with a dot after the format has taken place should work. With that said, give this a try...
Rich (BB code):
Private Sub TextBox4_AfterUpdate()
  TextBox5 = Replace(Format(Val(TextBox1) / Val(TextBox2) * Val(TextBox3) * Val(TextBox4), "0.0000"), ",", ".")
End Sub
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

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