hi all
can someone tell how i can multiply the items of combobox to onther one using vb.net , plz

## Recommended Answers

Can you give us an example of what you are trying to do? Can you list a simple case with the contents of two comboboxes and what you want to see as a result?

Multiply?
Do you mean, when you select an item on comboBox1, you ADD this item to comboBox2?
Is fo, use Add() method.

``````comboBox2.Items.Add(comobBox1.SelectedItem)
``````

Hi,

You could do something like this:

``````TextBox1.Text = Val(ComboBox1.SelectedItem) * Val(ComboBox2.SelectedItem)
``````

## All 11 Replies

Can you give us an example of what you are trying to do? Can you list a simple case with the contents of two comboboxes and what you want to see as a result?

Multiply?
Do you mean, when you select an item on comboBox1, you ADD this item to comboBox2?
Is fo, use Add() method.

``````comboBox2.Items.Add(comobBox1.SelectedItem)
``````

i have one combobox that have an price item and the other one have an QTY i need to multiply each item the show the result of sum in textbox , can anyone help plx
thx before :D

Hi,

You could do something like this:

``````TextBox1.Text = Val(ComboBox1.SelectedItem) * Val(ComboBox2.SelectedItem)
``````

hi luc001 , can u tell me how i can do inside a loop to make all item multply then take the sum of all, TY

Hi HibaPro,

can someone tell how i can multiply the items of combobox to onther one using vb.net

What are you trying to create and what do you have so far?

i want to calculate the total cost of Eq from two combobox
my code is
Dim sum As Integer

``````    For j = 0 To Me.ComboBox8.MaxLength

sum += ComboBox8.SelectedValue * ComboBox9.SelectedValue
``````

Next

``````    totalallcosttxt.Text += sum

but its calculate for the selected item not for all item or value

i try to do this from datagridview but i cant arrive to the clos value , can u help plz
``````

Hi,

The ComboBox is a combination of a TextBox and a ListBox. The ComboBox displays an editing field (TextBox) combined with a ListBox allowing us to select from the list or to enter new text.
That means that you only can calculate the selected items in both your comboboxes.

thx to guide me , but i would like to ask u if there is a method to calculate the total sum from datagridview

Thr following code assumes integer values in columns 0 and 1 of a datagridview. It calculates column0 + column1 and puts the result in column2. Use CDbl for floating point values. To calculate the total sum just keep a running total of the values in column2

``````For Each row As DataGridViewRow In DataGridView1.Rows
row.Cells(2).Value = CInt(row.Cells(0).Value) + CInt(row.Cells(1).Value)
Next
``````

well done, TY Reverend Jim and all who try to help me
TY TY TY

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.