Solved

Another question about Formatting Decimal Places in Visual Basic 2008

Posted on 2012-03-11
2
435 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

21 Experts available now in Live!

Get 1:1 Help Now