Click to See Complete Forum and Search --> : Format Result of Textbox "0.00"
ChrisOK
Jan 19th, 2006, 10:11 PM
Does anyone know how to fix this to show the result within the textbox like this: "0.00"
Right now, it appears like this: "252525."
I'm new to VBA and am trying to piece this together properly...
Everything seems to work great - except for this format problem...
Sub MyCalcQu()
If IsNumeric(TextBox7.Text) Then
If IsNumeric(TextBox8.Text) Then
If IsNumeric(TextBox13.Text) Then
TextBox3.Value = CDbl(TextBox7.Value) + CDbl(TextBox8.Value) + CDbl(TextBox13.Value)
'format the contents of the TextBox3 result
TextBox3.Value = Format(TextBox7.Value + TextBox8.Value + TextBox13.Value, "0.00")
End If
End If
End If
End Sub
Private Sub TextBox7_Change()
MyCalcQu
End Sub
Private Sub TextBox8_Change()
MyCalcQu
End Sub
Private Sub TextBox13_Change()
MyCalcQu
End Sub
Thanks! Chris
KGComputers
Jan 20th, 2006, 01:07 AM
Hi!!!
Are you using MS Access?
:) :) :)
mikeyc1204
Jan 20th, 2006, 09:32 AM
The problem is, you're trying to format a concatenated string. The values in your textboxes are "25", not 25. You converted to double to to get the value for your final textbox, but when formatting, you didn't convert.
"25" + "25" + "25" = "252525"
25 + 25 + 25 = 75
Just change TextBox3.Value = Format(TextBox7.Value + TextBox8.Value + TextBox13.Value, "0.00")
to TextBox3.Value = Format(cDbl(TextBox3.Value), "0.00")
ChrisOK
Jan 20th, 2006, 09:39 AM
This is for a user form in MS Excel.
The user plugs in their monthly numbers hits save/submit and this code sends their data into a spreadsheet (database within excel) - that auto-generates a bunch of charts used in executive briefings.....
Example: the user plugs in:
Number Shipped:_9__
Tot Days of All Shipped: _53__
Their result appears below like this: (so they can see the calculation occur
as they input their 2 numbers above)
Result:__5.89___
The problem with this is that the result field (TextBox3) is not adding the 3 numbers together -- it's sticking them together & showing a long result:
by putting '25' from textbox 7
and '25' from textbox 8
and '25' from textbox 13
together like this: '252525.' within this in the result field (Textbox3)
I need it to ADD the (3) 25's together tb7+tb8+tb13 and put the result into tb3 as: "75" (not 252525.)
mikeyc1204
Jan 20th, 2006, 09:42 AM
see the post directly above yours
ChrisOK
Jan 20th, 2006, 03:15 PM
The problem is, you're trying to format a concatenated string. The values in your textboxes are "25", not 25. You converted to double to to get the value for your final textbox, but when formatting, you didn't convert.
"25" + "25" + "25" = "252525"
25 + 25 + 25 = 75
Just change TextBox3.Value = Format(TextBox7.Value + TextBox8.Value + TextBox13.Value, "0.00")
to TextBox3.Value = Format(cDbl(TextBox3.Value), "0.00")
************
Mikey: The single line of code is EXACTLY what it needed to correct the problem!!
You are awesome! -- Thank you verrrrry much!
:bigyello: :D :bigyello:
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.