Link to home
Start Free TrialLog in
Avatar of jampost
jampostFlag for United States of America

asked on

Another question about Formatting Decimal Places in Visual Basic 2008

I am showing code below from two different areas of my program. The first one with the TextBox Text filled in by SQL Dataset which works fine. The second one with the TextBox Text filled in by code which triggers an error.  ( >>> “TBT.Text” Text is not a member of decimal<<<)  Decimals were OK TextBox56.Text, but not in TBT.Text. TBT.Text works fine in the program without the formatting code, except it goes out to 4 or 5 decimal places. What do I need to do different with the formatting code in TextBox TBT.Text to keep it at 2 decimal places? Thank you for any help.  


****TextBox Text is filled in by SQL Dataset****

Private Sub TextBox56_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox56.TextChanged

        Dim TB56 As Decimal

        If Decimal.TryParse(TextBox56.Text, TB56) Then

            Dim total As Decimal = (TB56)
            TextBox56.Text = total.ToString("#,##0.00")
        End If
    End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
****TextBox Text is filled in by code****

Private Sub TBT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TBT.TextChanged

        Dim TBT As Decimal

        If Decimal.TryParse(TBT.Text, TBT) Then          

>>> “TBT.Text” Text is not a member of decimal<<<

            Dim total As Decimal = (TBT)
            TBT.Text = total.ToString("#,##0.00")
        End If
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of Aruiz04
Aruiz04
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jampost

ASKER

That was it. Thank you