I am making a simple unit converter, and wanted the user to specify the number of decimal places to be displayed for the results.

The user selects which conversion they want to perform from another combo box, and I have a select case to decide the calculation needed. Eg.

Select Case cboUnitType.SelectedIndex
                Case 0 'grams to ounces
                    lcUnit2 = lcUnit1 * CSng(0.00220462262)
                    lblUnitResult.Text = CStr(lcUnit2)
                Case 1 'ounces to grams
                    lcUnit2 = lcUnit1 / CSng(0.00220462262)
                    lblUnitResult.Text = CStr(lcUnit2)
                Case 2 'kilograms to stones

etc.

Everything works fine here, but I am unsure how to use another combo box to change the decimal places of lblUnitResult.

I have tried

lblUnitResult.Text = Format(lcUnit2, "0.00")

and variations of this but it doesn't seem to work.

Any help would be grand.

how do I put that into a combo box now?

Sorry! Which value you want to put in the combo?


You can add an element into a combo,

combobox1.Items.Add("10")

Want to choose decimal point by selecting combo item.

lblUnitResult.Text = lcUnit2.ToString("N" & Combobox1.Text)

Oh that works, sorry if I asked my question wrong. thanks.

This question has already been answered. Start a new discussion instead.