473,387 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Masked Textbox and Percentages

Hi I have many textboxes that I need to have display percentages. I have used a masked textbox extender and the percentages display fine. using 99.99% as a mask and number as the mask type.

Now my problem is that i want it to be converted to a decimal when i save it to the database e.g 50% saves as 0.5 and then when it comes back from the database it must display as 50% again. This is needed for numerous calculations. IS there a way to do this?

Any help would be much appreciated.
Thanks in advance

Joss
Feb 11 '11 #1

✓ answered by yarbrough40

let's say that d is your decimal...
Expand|Select|Wrap|Line Numbers
  1. 'DISPLAY d AS A PERCENT
  2. FormatPercent(d)
  3.  
  4. 'CONVERT IT BACK TO A DECIMAL
  5. CDec(Replace(d, "%", "")) / 100

4 4486
yarbrough40
320 100+
let's say that d is your decimal...
Expand|Select|Wrap|Line Numbers
  1. 'DISPLAY d AS A PERCENT
  2. FormatPercent(d)
  3.  
  4. 'CONVERT IT BACK TO A DECIMAL
  5. CDec(Replace(d, "%", "")) / 100
Feb 13 '11 #2
Hi Yarbrough40 thanks for that i will give it a shot.

appreciate it
Feb 14 '11 #3
Yarbough40

Ok i tried what you said and it works fine to convert, but when it loads the converted number into the MaskedEditExtender the decimal values come out wrong. for example: 0.105 should display as 10.5% or 10.50% but instead it displays as 15.0%.

Just to reiterate the mask i am using is 99.99%
Feb 14 '11 #4
Ok never mind, my mask was incorrect 99.9% thanks again
Feb 14 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: cichy | last post by:
i spend a lot of time on looking for a masked textbox component... where i can find a free one for vc++ .net 2003 ? i found one but written in c# :o(( best regards marcin.
2
by: Brett Romero | last post by:
I have a masked textbox that excepts values of 0 thru 99. The mask is 00. Tabbing into this box is fine but if you click into it, you are one space over from the left. This means you can only...
3
by: Meelis Lilbok | last post by:
Hi Is it possible set mask in masked textbox for selected chars only? For example numbers 0-9 and letters A-F (hex. chars only) Best Regards; Mex
0
by: james.czebiniak | last post by:
newbie to .net I have a masked textbox intended to display/input salary. The mask is 999,999 or ###,###. When I place the info from the database into the field it formats incorrectly. The salary...
3
by: gayano | last post by:
Hi, I'm using Visual studio 2005 pro Ver..]]] I have a Form named form1 textbox named txtName masked textbox (Date Masked) named txtMaskedDate and a button to add data named btnAdd dim...
2
by: steve waugh | last post by:
Hi I want to use Masked TextBox Control in my ASP.NEt application. The same is used in C# on Window Appliation but i want to use in my Web Application, is there any way out Thx
0
by: michels287 | last post by:
I have a masked textbox on my form. I have an onscreen keyboard with numbers only. The masked format for the masked textbox is: (###) ### - #### I want to make sure they enter the phone...
0
by: JoeP | last post by:
Hi All, How can you manage to have money with a dollar sign in a masked textbox? I tried enter this one in the mask propert as: $999,999.99 but it does not work for me. Any idea? Thanks,
0
by: =?Utf-8?B?UGFvbG8=?= | last post by:
I have a masked textbox with following mask: #####.## with a Validating Type of decimal. (It's a currency input field) I would like the cursor to position itself in the first spot to the left of...
3
by: buddyr | last post by:
Hello, I have a texbox with error provider control: if(textbox.text.length <=0) { errorprovider1.seterror(textbox,"enter part number"); } else { errorprovider1.seterror(textbox, "");
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.