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.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Something like this ...
VBA Code:
TextBox1.Value = Format(0.26211111115534, "0.0000")
 
Upvote 0
excuse,

but after all it doesn't work ... round the number to 4 decimal places but cancel the multiplication resultin the texbox ... always 0.2621 ... what I want is for the textbox to always keep the decimal places but present the result of my calculation regardless of the outcome
 
Upvote 0
My example was meant to get you on the right track. In your situation, replace the number in my example with the result of your multiplication, or with the expression of the multiplication itself if you like.
VBA Code:
    Dim x
    Dim y
    Dim result
   
    x = 1.2532
    y = 0.65432
    result = x * y
   
    TextBox1.Value = Format(result, "0.0000")
    '  or ...
    TextBox1.Value = Format(x * y, "0.0000")
 
Upvote 0
My example was meant to get you on the right track. In your situation, replace the number in my example with the result of your multiplication, or with the expression of the multiplication itself if you like.
VBA Code:
    Dim x
    Dim y
    Dim result
  
    x = 1.2532
    y = 0.65432
    result = x * y
  
    TextBox1.Value = Format(result, "0.0000")
    '  or ...
    TextBox1.Value = Format(x * y, "0.0000")


SORRY NOT WORKING...IM GOING TO POST THE VBA CODE
 
Upvote 0
VBA CODE...VERY SIMPLE BUT A LOT OF TROUBLE...o_Oo_Oo_O

Private Sub TextBox4_AfterUpdate()

TextBox5 = Val(TextBox1) / Val(TextBox2) * Val(TextBox3) * Val(TextBox4)

End Sub


I NEED THE TEXTBOX 5 TO REDUCE THE DECIMAL PLACES TO 4...IN THIS IMAGE 0.2621 SHOULD BE THE RESULT

FOR ME ITS NOT EASY...VBA FOR ME IM A "0"

THANKS EVERYONE
 

Attachments

  • 1.jpg
    1.jpg
    20.5 KB · Views: 3
Last edited:
Upvote 0
VBA CODE...VERY SIMPLE BUT A LOT OF TROUBLE...o_Oo_Oo_O

Rich (BB code):
Private Sub TextBox4_AfterUpdate()
  TextBox5 = Format(Val(TextBox1) / Val(TextBox2) * Val(TextBox3) * Val(TextBox4), "0.0000")
End Sub
Try adding what I show in red above...
 
Upvote 0
AMAZING ??? PROBLEM SOLVED.

THANK YOU VERY MUTCH SR.RICK.
 
Upvote 0
AFTER A HELPFUL FROM SR RICK FINALLY GOT TO FORMAT THE FINAL RESULT FOR 4 DECIMAL HOUSES ... NOW THE RESULT APPEARS 0,2621... IS THERE ANY WAY TO PLACE A POINT TO BE 0.2621?

TANK YOU.
 

Attachments

  • 2.jpg
    2.jpg
    13.8 KB · Views: 3
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,721
Members
449,093
Latest member
Mnur

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