At the end of a calculation Pweight stores a number, I need to format this number so that it only shows to 2 decimal places.. I have tried this:
This actually seems to make it miss calculate, so I've put it back to Pweight.ToString() and left it at that but I get around 12 decimal places.
VB.NET:
If cmbSub.SelectedItem = "NAC(N - acetlycsteine)" Then
While i > 0
'Calculate current weight - % annual deterioration
Pweight = Pweight - (Pweight * Deterioration / 100)
'remove 1 year from each succesful loop
i = i - 1
End While
txtResult.Text = Pweight
lblMsg2.Text = Today + "."
lblMsg3.Text = "This is a calculation of the deterioration of " + Oweight.ToString()
lblMsg4.Text = "Grams of " + cmbSub.SelectedItem + " substance. The amount remaining of " + cmbSub.SelectedItem + " after " + cmbYear.SelectedItem + " years is " + Pweight.ToString(Format(1.9, "0.00")) + "."
End If
This actually seems to make it miss calculate, so I've put it back to Pweight.ToString() and left it at that but I get around 12 decimal places.