# How to conversions of number I loose my significant values.

I have code below that will take a number (0.3346) in inches and convert it back into mm. The top part of the code after I multiply by 25.4 give me (8.4988D) It should suppose to give me 8.50 mm then what I need to do is take that (8.4988D) value and convert it to a nice round number of 8.50.
I thought the code below would do that with using decimal instead of a double type.

Can anyone offer a suggestion?

`````` Dim number As Decimal
number = Me.txtProbeOffset.Text * 25.4
Me.txtProbeOffset.Text = number
Select Case number
Case 0 To 9
If Me.txtProbeOffset.Text.Contains(".") Then
GaugeOffset = Me.txtProbeOffset.Text.Replace(".", "")
GaugeOffset = "0" & GaugeOffset & "0"
If GaugeOffset.Length = 5 Then
GaugeOffset = GaugeOffset.Remove(GaugeOffset.Length - 1)
End If
Else
GaugeOffset = "0" & Me.txtProbeOffset.Text & "0" & "0"
If GaugeOffset.Length = 5 Then
GaugeOffset = GaugeOffset.TrimEnd("0")
End If
End If
Case 10 To 99
'If Me.txtProbeOffset.Text.Contains(".") Then
'    GaugeOffset = Me.txtProbeOffset.Text.Replace(".", "")
'    GaugeOffset = GaugeOffset & "0"
'Else
GaugeOffset = number & "0" & "0"
'End If
Case Else
Me.ErrWarning.SetError(Me.txtProbeOffset, "Value entered must be in a correct format.MAX value is 5 characters.")
WirelessGageSetupMode.Text = "Value entered must be in a correct format.MAX value is 5 characters."
ConnectionStatus.BackColor = System.Drawing.Color.Yellow
Exit Sub
End Select
``````
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Senior .Net ConsultantCommented:
you should use Math.Round (https://msdn.microsoft.com/en-us/library/zy06z30k(v=vs.110).aspx):

``````number = Math.Round(Me.txtProbeOffset.Text * 25.4, 2)
``````
1

Experts Exchange Solution brought to you by