Click here to Skip to main content
15,886,100 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how can i multiply the items in combobox and unitprice?
Posted
Comments
Richard MacCutchan 20-Jul-12 4:48am    
There is a feature of mathematics known as multiplication where (in simple terms)
product = value times multiplier.
Now if you have a proper programming question perhaps you would like to edit the above and fill in the details.
OriginalGriff 20-Jul-12 4:51am    
You do have to wonder why some of these people have chosen a career in IT...:sigh:
Richard MacCutchan 20-Jul-12 5:06am    
I just hope they aren't working for my bank.
Sebastian T Xavier 20-Jul-12 4:49am    
What have you tried?
lenuj123 20-Jul-12 5:18am    
this is what ive tried
If Combo1.SelectedItem <= 20 Then
txtBox2.Text = 20
txtBox3.Text = Combo1.SelectedItem * txtBox2.Text
ElseIf Combo1.SelectedItem <= 50 Then
txtBox2.Text = 15
txtBox3.Text = Combo1.SelectedItem * txtBox2.Text
ElseIf Combo1.SelectedItem <= 100 Then
txtBox2.Text = 12
txtBox3.Text = Combo1.SelectedItem * txtBox2.Text
ElseIf Combo1.SelectedItem <= 500 Then
txtBox2.Text = 8
txtBox3.Text = Combo1.SelectedItem * txtBox2.Text
ElseIf Combo1.SelectedItem >= 500 Then
txtBox2.Text = 5
txtBox3.Text = Combo1.SelectedItem * txtBox2.Text

Convert them to numbers, using Parse or TryParse, and (as Richard says) use the multiplication operator "*" to produce a result:
C#
int x = int.Parse(myCombo.SelectedItem.ToString());
int y = int.Parse(myTextbox.Text);
int res = x * y;
 
Share this answer
 
C#
int item1 =int.Parse(Product.SelectedValue.ToString());
int unitPrice=int.Parse(UnitPrice.SelectedValue.ToString());

int result = item1 *  unitPrice
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900