Convert Combobox percent to double variable
vb.net, vba, visual-studio-2010, visual-studio-2012, windows
Solution
Use `String.Replace("%","")` to replace the "%" and then `Double.TryParse()` to convert the string to double
Problem
I am using VB.Net to create an amortization calculator using visual studio 2012. I have a combo box that contains a list of percentages: ``` Dim dblInterest As Double Dim InterestRateInput For InterestRateInput = 20 To 2000 Step 1 dblInterest = Math.Round(InterestRateInput / 10000, 4) cboInterestRateInput.Items.Add(FormatPercent(dblInterest)) ``` Since I formatted the value to a percent I can no longer convert it to a double because it has the "%" sign in it. How would I convert the percentages to a double after the user selects the desired percent? I am trying to execute this line of code without success: ``` dblAnnualRate = CDbl(cboInterestRateInput.Items(cboInterestRateInput.SelectedIndex)) ``` EDIT: To resolve this issue I did dblAnnualRate = CDbl(cboInterestRateInput.Items(cboInterestRateInput.SelectedIndex).ToString.Replace("%", "")) Added another variable which I set equal to dblAnnualRate /100