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

x
?
Solved

ASP.NET 2005 - String.Format doesn't affect a text box!

Posted on 2008-06-20
5
Medium Priority
?
542 Views
Last Modified: 2013-11-26
Hi,

I am trying to format some numbers in my text box by using:

Me.Subscribed_QTY.Text = Format(Me.Subscribed_QTY.Text.ToString, "{0:##,#}")

However, if the value of the text box is 1000 it doesn't change! What should I do?

0
Comment
Question by:feesu
[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
  • 2
5 Comments
 
LVL 10

Expert Comment

by:NeoTeq
ID: 21833537
You will need to convert it to a number before it can format it as one.
Me.Subscribed_QTY.Text = CType(Me.Subscribed_QTY.Text, Decimal).ToString("{0:##,#}")

Open in new window

0
 

Author Comment

by:feesu
ID: 21835748
Hi NeoTeq,

I tried what you sent me. It doesn't work.
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 250 total points
ID: 21847739
If the value of the text box is always Integer, then you can try:
Me.Subscribed_QTY.Text = String.Format("{0:##,#}", Int32.Parse(Me.Subscribed_QTY.Text))
If the value of the text box is always Decimal, then you can try:
Me.Subscribed_QTY.Text = String.Format("{0:##,#}", Decimal.Parse(Me.Subscribed_QTY.Text))

The second one will also work for Integer values.
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 21885207
If you got your answer, will you please close the question?
0
 

Author Comment

by:feesu
ID: 21895827
prairiedog,

I have tested this code, and observed the following:

1- The formatted number inside the text box cannot be used in calculations; 60,000 is read as 60 !

2- I needed to format the text box even if it's empty but  I am getting an error. How can I do that?

Currently I call this:
 Me.Subscribed_QTY.Text = String.Format("{0:##,#}", Decimal.Parse(Val(Me.Subscribed_QTY.Text)))



Thanks for helping me cuz I'm new to this.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

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