-
I would like to have results show in my txt box with no more than 2 places after decimal (0.00). I tried selecting the data format property on the txt box and setting it to how I would like, but it doesn't seem to do anything. Ideas?
Thank You! (again)
-
Code:
dVal = 3.141592654
Text1.Text = Format(dVal,"#,##0.00")
-
I'm confused.
1. What does the "dVal = 3.141592654" represent/do
2. Where does this go?
-
dVal = 3.141592654
Text1.Text = Format(dVal,"#,##0.00")
dVal can be Integer.
Text1.Text = Format(dVal,"#,##0.00")
becomes the result.
Format = Format function (take a look in your VB Help File or MSDN Library for "format function".)
Copy and then paste it into the Form_Load event or wherever you want.
Basically, dVal is the variable which is holding the number and then it is formated to do what you want: get only 2 decimal places and that's it.
So your code would look like this:
Code:
Private Sub Form_Load()
Dim dVal As Integer
dVal = 3.141592654
Msgbox Format(dVal,"#,##0.00")
End Sub
Hope that explains a bit more.
Did I :confused:confuse:confused: you a bit more? :rolleyes:
It's not the best explaination, but may get you somewhere.
-
Maybe I'm explaining this wrong.
This is what I have now:
txtAve.Text = (Val(txt1a) + Val(txt2a)) / (Val(txt1) + Val(txt2))
Currently when you click the cmd button that calculates txtAve's result, you get multiple positions past the decimal. I want to limit how many spaces.
I'm sorry if I've made this so confusing.
Thanks again.
-
Do you want to round the final answer?
Because you can use the Round function to do it.
Code:
'Round(number,decimal place)
'=Round(number,2)
txtAve.Text = Round((Val(txt1a) + Val(txt2a)) / (Val(txt1) + Val(txt2)), 2)
So it will be rounded and only show the number and 2 decimal places.
-
Why wouldn't you just declare the variable that the txtbox is outputting as a Double?
-
You may could use this if you don't need it rounded
txtAve = Format(txtAve, "Fixed")
This would give you two decimal places.
JO
[Edited by joltremari on 11-20-2000 at 05:28 PM]