Anthony Cox Anthony Cox - 1 month ago 10
Vb.net Question

how to add (plus) to a cell using a textbox

i need to add a number to textbox for everytime a specific item that was used to a cell in excel using vb. For example, for everytime the word "Time" is selected from the combobox1, it must add 1 to cell B2. and if "Time" is selected again. it must add 1 again to cell B2. Then cell B2 must have "2" in it

ive tried this, but it doesnt seem to work:

Dim Scrap As String

Scrap = ComboBox1.Text
Select Case Scrap
Case "Aluminium"
worksheet2.Cells(4, 3) = +AmountBox.Text
worksheet2.Cells(4, 4) = +KiloBox.Text
worksheet2.Cells(4, 2) = +1 'adds 1 for each time this type of scrap is used
end select

Answer
Dim Temp as Integer = CInt(worksheet2.Cells(4, 2).Value)
Temp += 1
worksheet2.Cells(4, 2).Value = Temp

Try something like this

This as well can do it:

worksheet2.Cells(4, 2) = (worksheet2.Cells(4, 2).Value + 1)