I want to know how to convert a percentage rate such as 4.5% into a decimal number in your code editor in V 2008.

For example, the user input is 4.5%. Is there any function available to convert is to 0.045? Thanks,

# Convert a percentage to a decimal number

Page 1 of 1## 4 Replies - 25161 Views - Last Post: 05 May 2011 - 02:26 PM

##
**Replies To:** Convert a percentage to a decimal number

### #2

## Re: Convert a percentage to a decimal number

Posted 03 February 2010 - 04:59 PM

you could make a function in a module. The code would really be quite simple, here is an example I've made:

Hope this helps

Function ToDecimal(Percentage As String) As Double Percentage = Left(Percentage, Len(Percentage) - 1) 'removes percentage sign' ToDecimal = Val(Percentage) / 100 'makes the percentage string a number using Val(), divides that by' '100 to get a decimal and then makes the function return that value' End Function

Hope this helps

This post has been edited by **rainbow evil**: 03 February 2010 - 05:04 PM

### #3

## Re: Convert a percentage to a decimal number

Posted 05 May 2011 - 09:44 AM

rainbow evil, on 03 February 2010 - 04:59 PM, said:

you could make a function in a module. The code would really be quite simple, here is an example I've made:

Hope this helps

Function ToDecimal(Percentage As String) As Double Percentage = Left(Percentage, Len(Percentage) - 1) 'removes percentage sign' ToDecimal = Val(Percentage) / 100 'makes the percentage string a number using Val(), divides that by' '100 to get a decimal and then makes the function return that value' End Function

Hope this helps

Hi

Thanks for the great example, what does "Left" mean in your code and it gives me an error.

### #4

## Re: Convert a percentage to a decimal number

Posted 05 May 2011 - 09:52 AM

It's grabs the 'left' part of a string up to the length passed as the second parameter.

Left("hello", 3)

will return

"hel"

Left("hello", 3)

will return

"hel"

### #5

## Re: Convert a percentage to a decimal number

Posted 05 May 2011 - 02:26 PM

Page 1 of 1