Solved

Another question about Formatting Decimal Places in Visual Basic 2008

Posted on 2012-03-11
2
438 Views
Last Modified: 2012-03-11
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
0
Comment
Question by:jampost
2 Comments
 
LVL 5

Accepted Solution

by:
Aruiz04 earned 500 total points
ID: 37707554
You have both the decimal variable and the textbox named the same TBT, try different names
0
 

Author Closing Comment

by:jampost
ID: 37707603
That was it. Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now