i have a userform that includes combox and two textboxes the user choose a chemical (text) from the combobox1 and enters the height of the chemical in textbox1 (number). then according to the chemical he choose i define the density and area of the tank of the chemical. then i need to calculate: textbox2.value=density*area*textbox1.value density and area are different for every chemical. the equation is mass=density*area*volume. i tried this code: Private Sub ComboBox1_Change() Dim chem As String
chem = ComboBox1.Value
mychem
End Sub
Sub mychem()
Dim density As Double
Dim volume As Double
If chem = "Sodium" Then
area = 22
density = 1.058
End If
If chem = "HCl 9%" Then
area = 22
density = 1.043
End If
If chem = "alum" Then
area = 70
density = 1.163
End If
If IsNumeric(Txtheight.Text) Then
txtmass.Value = density *area * CDbl (Txtheight.Value)
End If
end sub