Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why the two number after the decimal point are always converted to two

Status
Not open for further replies.

piscis

Programmer
Jun 26, 2003
29
PR
Gentleman:

Does anyone knows why the two number after the decimal point are always converted to two zeros with the code below?

Example:

If the real value was 175.53

I only get 175.00

Why is this?

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Dim MyRegEx As New Regex(&quot;=\s+(?<MyPat>\d+)&quot;)
Dim s As String = txtDataView.Text
Dim Mc As MatchCollection = MyRegEx.Matches(s)
Dim M As Match
Dim i As Integer
If Mc.Count > 0 Then
i = 0
For Each M In Mc
i += 1
PutInTextBox(Me, &quot;TextBox&quot; & CStr(i), M.Groups(&quot;MyPat&quot;).Value)
Next
End If

End Sub



Private Sub PutInTextBox(ByVal ContainerCtrl As Control, ByVal TBName As String, ByVal msg As String)
Dim ctl As Control
For Each ctl In ContainerCtrl.Controls
If TypeOf ctl Is TextBox And ctl.Name = TBName Then
ctl.Text = msg
Exit For
Else
PutInTextBox(ctl, TBName, msg)
End If
Next

End Sub
 
i is an integer, and only collecting data before the decimal point (i +=1)

wouldn't str() work better to convert a number to a string?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top