Is there an easy way to format a % into a normal number?
For example, 55.5% into .555?
I've written some code to do it, but it's quite a few lines so was wondering if there is a way to do it in 1-3 lines.
Printable View
Is there an easy way to format a % into a normal number?
For example, 55.5% into .555?
I've written some code to do it, but it's quite a few lines so was wondering if there is a way to do it in 1-3 lines.
Replace the "%" with nothing and divide result by 100:
Code:MsgBox CSng(Replace("55.5%", "%", "")) / 100
*sigh*
I always get embarrassed by things like this :P Always trying to find the most complicated method ever.
Thanks!
You're welcome.
And there is nothig to be embarrassed about - people do thing in 1000 different ways so I'm sure you will get another dozen or so suggestions.
Regards. :wave:
very true Rhino :)
I follow this in VBA Excel
Not sure if "general" will work in vb6Code:Sub formatnumber()
sss = "55.5%"
MsgBox Val(Format(sss, general))
End Sub
And, this will remove the leading 0 from Rhino's code if that is a requirement:
Code:MsgBox Format$(CSng(Replace("55.5%", "%", "")) / 100, "#.000")