Click here to Skip to main content
15,845,436 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to multiply Combobox with Textbox, How can i solve this.

What I have tried:

private void button1_Click(object sender, EventArgs e)
        {
            int x = 0;
            string p1 = txt1.SelectedItem.ToString();//Combobox
            if(p1 == "HTML/CSS")
            {
                x += 4200;
            }
            else if(p1 == "Photoshop/Illustrator")
            {
                x += 4000;
            }
            else
            {
                x += 3500;
            }
            string p2 = txt2.SelectedItem.ToString();//Combobox
            if(p2 == "JavaScript")
            {
                x += 5700;
            }
            else if(p2 == "PHP")
            {
                x += 6000;
            }
            else if(p2 == "Java")
            {
                x += 5000;
            }
            else
            {
                x += 4500;
            }
            string p3 = txt3.SelectedItem.ToString();//Combobox
            if(p3 == "Ալգորիթմների տեսություն")
            {
                x += 12500;
            }
            else
            {
                x += 15000;
            }
            string y = txt4.Text; //Textbox
            int z = y * (p1 + p2 + p3)

        }
Posted
Updated 20-Feb-18 1:23am
Comments
BillWoodruff 20-Feb-18 22:42pm    
In TextBox 4: can the user enter a floating-point number ?

1 solution

Convert your string values to integers with int.Parse() or decimal.Parse() etc.
 
Share this answer
 
Comments
Suren97 20-Feb-18 6:01am    
i changed, but it give me error again, it says cannot implicity convert type "double" to "string"
Mehdi Gholam 20-Feb-18 8:06am    
At what line does it say that?
BillWoodruff 21-Feb-18 2:22am    
"Convert your string values to integers with int.Parse() or decimal.Parse() etc."

I think you mean: Convert your string values to integers with int.Parse(), or, convert them to a floating-point Type, like 'decimal, or 'double, using their 'Parse or 'TryParse methods.

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