Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Another question about Formatting Decimal Places in Visual Basic 2008

Posted on 2012-03-11
2
Medium Priority
?
447 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 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