Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2007

Tip: Looking for answers? Try searching our database.

Format a textbox to display as a percentage

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 15 Oct 2007 10:52 GMT
Arrggg…Format String Hell…Hello there,

I am attempting to format a decimal value as a % (percentage).
That is; I want .12 to be displayed and edited as 12%
No matter what I try I cant get it to work  :(
I can get it working for display format, but not for the editformat :(

Below is my code

Me.txtDefaultAdminFeePercentage.Properties.DisplayFormat.FormatType =
FormatType.Numeric
Me.txtDefaultAdminFeePercentage.Properties.DisplayFormat.FormatString =
"{0:0%}"
Me.txtDefaultAdminFeePercentage.Properties.EditFormat.FormatType =
FormatType.Numeric
Me.txtDefaultAdminFeePercentage.Properties.EditFormat.FormatString =
"{0:0%}"

Any ideas would be greatly appreciated

Thank you for taking the time to read my post
John
Phillip Taylor - 15 Oct 2007 11:26 GMT
> Arrggg...Format String Hell...Hello there,
>
[quoted text clipped - 18 lines]
> Thank you for taking the time to read my post
> John

Instead of using a textbox you might try using the masked text box
control instead (it should be listed in the components somewhere).
Then set the mask property. I'm sure this kind of thing is ideal for
it's use.

Phill
Rad [Visual C# MVP] - 15 Oct 2007 18:17 GMT
>Arrggg…Format String Hell…Hello there,
>
[quoted text clipped - 18 lines]
>Thank you for taking the time to read my post
>John

The format string you want is {0:p}

That will give you 12.00%

--
http://bytes.thinkersroom.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.