sum format number textbox in userform

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hi, expert

i need help the adjusted these codes
i have userform contains textbox1,2,3
the textbox1 :
Private Sub TextBox1_AfterUpdate()


TextBox1.Value = Format(TextBox1.Value, "####.00")
end sub
and textbox2:
Private Sub TextBox2_AfterUpdate()
TextBox2.Value = Format(TextBox2.Value, "#,###.00")
end sub
textbox3:
TextBox3.Value = Format(TextBox3.Value, "#,###.00")
end sub


here the textbox3 is not show the right result for instance when add the numbers textbox1 =500.00 and textbox2=1,250.00 it gives me textbox3=500
is there any way adjust code to give me right result in textbox3 = 625,000.00
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You can put the code where you perform the operation to fill the textbox3.

Try this:

Code:
Private Sub TextBox1_AfterUpdate()
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
  TextBox1.Value = Format(TextBox1.Value, "#,###.00")
End Sub


Private Sub TextBox2_AfterUpdate()
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
  TextBox2.Value = Format(TextBox2.Value, "#,###.00")
End Sub
  
Private Sub TextBox3_AfterUpdate()
  TextBox3.Value = Format(TextBox3.Value, "#,###.00")
End Sub
 
Last edited:
Upvote 0
You can put the code where you perform the operation to fill the textbox3.

Try this:

Code:
Private Sub TextBox1_AfterUpdate()
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
  TextBox1.Value = Format(TextBox1.Value, "#,###.00")
End Sub


Private Sub TextBox2_AfterUpdate()
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
  TextBox2.Value = Format(TextBox2.Value, "#,###.00")
End Sub
  
Private Sub TextBox3_AfterUpdate()
  TextBox3.Value = Format(TextBox3.Value, "#,###.00")
End Sub
thanks i tested your codes but not queit work when i fill in textbox1 1,111 and textbox2 1,111 give me in textbox3 only 1234321 i would like this 1,234,321
 
Last edited:
Upvote 0
Try

Code:
Private Sub TextBox1_AfterUpdate()
  TextBox3.Value = ""
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
  TextBox1.Value = Format(TextBox1.Value, "#,###.00")
End Sub


Private Sub TextBox2_AfterUpdate()
  TextBox3.Value = ""
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
  TextBox2.Value = Format(TextBox2.Value, "#,###.00")
End Sub


Private Sub [COLOR=#0000ff]TextBox3_Change[/COLOR]()
  TextBox3.Value = Format(TextBox3.Value, "#,###.00")
End Sub
 
Last edited:
Upvote 0
Try

Code:
Private Sub TextBox1_AfterUpdate()
  TextBox3.Value = ""
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
  TextBox1.Value = Format(TextBox1.Value, "#,###.00")
End Sub


Private Sub TextBox2_AfterUpdate()
  TextBox3.Value = ""
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
  TextBox2.Value = Format(TextBox2.Value, "#,###.00")
End Sub


Private Sub [COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=00]#00[/URL] 00ff]TextBox3_Change[/COLOR]()
  TextBox3.Value = Format(TextBox3.Value, "#,###.00")
End Sub

it still the problem continue i noticed one thing after i fill data in textbox1,2 and i press in textbox 3 show what i would but i want show the result in textbox 3 directly when i add the data in textbox1,2
 
Upvote 0
Try this

Code:
Private Sub TextBox1_Change()
  TextBox3.Value = ""
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
End Sub


Private Sub TextBox2_Change()
  TextBox3.Value = ""
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
End Sub


Private Sub TextBox2_AfterUpdate()
  TextBox2.Value = Format(TextBox2.Value, "#,###.00")
End Sub


Private Sub TextBox1_AfterUpdate()
  TextBox1.Value = Format(TextBox1.Value, "#,###.00")
End Sub


Private Sub TextBox3_Change()
  TextBox3.Value = Format(TextBox3.Value, "#,###.00")
End Sub
 
Upvote 0
Solution
Try this

Code:
Private Sub TextBox1_Change()
  TextBox3.Value = ""
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
End Sub


Private Sub TextBox2_Change()
  TextBox3.Value = ""
  If TextBox1 <> "" And TextBox2 <> "" Then
    TextBox3.Value = CDbl(TextBox1) * CDbl(TextBox2)
  End If
End Sub


Private Sub TextBox2_AfterUpdate()
  TextBox2.Value = Format(TextBox2.Value, "#,###.00")
End Sub


Private Sub TextBox1_AfterUpdate()
  TextBox1.Value = Format(TextBox1.Value, "#,###.00")
End Sub


Private Sub TextBox3_Change()
  TextBox3.Value = Format(TextBox3.Value, "#,###.00")
End Sub

thanks more again but the problem i have to press textbox3 to show what i would
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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