How to format a percent number as decimal using string.format in VB?

Hi,

I have a GridView-Control with labels which contain numbers in percentformat, which are formatted in the RowDataBound-Event, but when I try to update the GridView i get the Invalid String format Exception because the labels are in the percentage Format like -27,5% but i need this number as double-value like 0.275. How can I convert the number from percentage to number? Any idea?

 Thanks in forward,

 Vlad

0
koschaksito
12/12/2007 7:38:36 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
1010 Views

Similar Articles

[PageSpeed] 53

 

Dim str as string = percentlabel.Text
' Get rid of percentage sign
str = str.Replace("%", "")
' Check if you can convert
dim dbl as double
if not (double.tryparse(str, db)) then exit sub
' Successfully converted

' divide by 100 to get percent
dbl = dbl / 100
 
0
codeasp
12/12/2007 8:26:13 PM
Reply:

Web resources about - How to format a percent number as decimal using string.format in VB? - asp.net.presentation-controls

Percent sign - Wikipedia, the free encyclopedia
The percent sign ( % ) is the symbol used to indicate a percentage , a number or ratio as a fraction of 100. Related signs include the permille ...

STUDY: 7 Percent Of Facebook Brand Page Posts Are Considered Spam
According to a recent survey among 9,000 Facebook brand pages, 7 percent of all posts published are considered spammy by the users. It is Komfo ...

Dealmaster: Save over 50 percent on the Lenovo Yoga Pro 3 ultrabook
... savings on some of Lenovo's newest devices. One of the best deals is on the 2015 Lenovo Yoga Pro 3 ultrabook—you can save over 50 percent on ...

You share 70 percent of your genes with this slimy worm
Scientists sequenced the genome of two primitive worm species and made some surprising discoveries

The 3 stocks that yield more than 8 percent
These stocks are offering the yield of dreams. But are their rich dividend payouts secure?

Tinder users jump 400 percent in India over a year
The popular dating app has enjoyed incredible growth in India, where smartphone and Internet connectivity are hitting new highs.

Poll: 60 Percent Of Americans Against Taking In Refugees
Poll: 60 Percent Of Americans Against Taking In Refugees

One of the Steam Machines is already 40 percent off
Less than two weeks after it hit the market, Syber is already discounting one of its Steam Machines by 40 percent. As part of a "one day only!" ...

Weather Causes 90 Percent of Global Disasters: UN
Global catastrophes over the last 20 years includes 6,457 recorded floods, storms, heatwaves, and the like.

Chill optional: 51 percent of US internet users watch Netflix
Netflix's robust content library has helped it top nearly 70 million subscribers worldwide. Not surprisingly, the majority of those come from ...

Resources last updated: 11/27/2015 3:39:02 PM