PDA

View Full Version : an empty textbox in a formula



eran3185
04-29-2007, 01:10 PM
i have form
this form calculate this formula : TextBox1 * TextBox2 = TextBox3.
but when textbox1 or TextBox2 is empty , there is "run time error 13 type mismatch"
what can i do to make the formula to work ok when one textbox is empty (ie 6 * " " = 0) ?

mdmackillop
04-29-2007, 02:03 PM
Use a function to convert "" to 0
Private Sub CommandButton1_Click()
TextBox3.Value = FixTB(TextBox1.Value) * FixTB(TextBox2.Value)
End Sub

Function FixTB(Num)
If Num = "" Then
FixTB = 0
Else
FixTB = Num
End If
End Function