Solved

format a textbox to remove .000

Posted on 2013-01-23
8
400 Views
Last Modified: 2013-02-08
Hi

I have a textbox that gets assigned qty values but it appears as e.g. 126.000 and would like it to be 126.

any ideas?

Thanks
0
Comment
Question by:razza_b
[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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 3

Expert Comment

by:Khilu
ID: 38809405
Use  following code to make it int and then assign to textbox
int n = Convert.ToInt32(value);

Open in new window


You can directly convert it to string by following code.

 decimal value = 3.14m;
string stringValue = ((int)value).ToString();

Open in new window

0
 
LVL 1

Author Comment

by:razza_b
ID: 38809492
i have tried converting and doesnt work...

if (dgr.PassQty < Convert.ToInt32(tbWorkOrderQty.Text))
0
 
LVL 3

Expert Comment

by:Khilu
ID: 38809594
Try this

  int thisInt;
            Int32.TryParse(tbWorkOrderQty.Text, out thisInt);
            if (dgr.PassQty < thisInt)
            {
                //Your code
            }

Open in new window

0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 44

Expert Comment

by:AndyAinscow
ID: 38809617
How do you assign the value to the textbox ?  (In other words are formatting a string to force it show 3 decimal places in your code ?)

You say textbox.  Do you mean edit OR maskededit box?  A maskededit box has a mask property - which can be set to force decimal places to be shown.
0
 
LVL 1

Author Comment

by:razza_b
ID: 38809620
simple...

 tbWorkOrderQty.Text = tbWorkOrderQty.Text.Replace(".000", "");
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 38809661
Simple - wouldn't it be better to make it work correctly at the start rather than patching it.

ps.  If that works then it isn't a problem with a mask in a maskededit.
0
 
LVL 1

Author Comment

by:razza_b
ID: 38809689
it always come back with this .000 for every value and the textbox is a readonly so no one can edit it shouyld be fine

but what do you mean by mask edit?
0
 
LVL 10

Accepted Solution

by:
Monica P earned 500 total points
ID: 38813212
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

726 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