Is there a better way to parse percentage to double like this?
Dim Buffer As String = "50.00%"
Dim Value As Double = Double.Parse(Buffer.Replace("%",""), NumberStyles.Any, CultureInfo.InvariantCulture) / 100
The way you are doing it seems good to me.
The only point I would be careful about is that your program is assuming InvariantCulture. Make sure this is actually what you mean. For example it might be better to use the machine's default culture if your string comes from user input rather than a fixed well-defined protocol.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With