Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Another question about Formatting Decimal Places in Visual Basic 2008

Posted on 2012-03-11
2
Medium Priority
?
451 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

963 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