954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

choosing decimal places from combo box

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.

Funsize
Newbie Poster
5 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 
lblUnitResult.Text = lcUnit2.ToString("N2")
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

how do I put that into a combo box now?

Funsize
Newbie Poster
5 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 
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)
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

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

Funsize
Newbie Poster
5 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: