We help IT Professionals succeed at work.

Creating a mask for a percentage

vlvawter
vlvawter asked
on
Medium Priority
580 Views
Last Modified: 2006-11-18
I am trying to create a mask in order to show a percentage.  I've tried "99.99%" and variations, but nothing works.  

I have a textbox that is displaying a float from a database.  I don't want it to show 25.1, but 25.1%.  I know I can go in and adjust the textbox.text, but I'd rather just have a mask.  I will having a lot more of these down the road.  
Comment
Watch Question

Director, IT and Business Development
Commented:
hmm try either one of these

LblPctTotal = Format(lblPctTotal, ?Percent?)


or any of these ways of calling FormatPercent

lblTotalPct = FormatPercent(NumToFormatAsPercent)

lblSumPct = FormatPercent(NumToFormatAsPercent, NumOfPlaces)

lblCurrInterest = FormatPercent(CurrentInterest)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Leo EikelmanDirector, IT and Business Development

Commented:
if u wanted to actually mask it look at this

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconusingmaskededitcontrol.asp


You would use the .Mask property and specify 0% for percentages


Cheers,

Leo
Leo EikelmanDirector, IT and Business Development

Commented:
I think in my first post I made a typo

this line

LblPctTotal = Format(lblPctTotal, ?Percent?)

should read

LblPctTotal = Format(lblPctTotal, "Percent")


Cheers,

Leo


Const strFormat = "#0.0#%"

debug.print format(.251,strformat)
Leo EikelmanDirector, IT and Business Development

Commented:
Both mine and g_johnson's techniques will work, split points.

Leo
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.