First of all with
Code:
Dim y, y1, y2 As Double
y and y1 are Variants. Only y2 is a Double.
Your code fills in txtGencorev.Text when the form first opens. Move everything to a different location.
Code:
Private Sub Form_Load()
End Sub
ââââââââââââââââââââââââââââââââââââââââ
Private Sub txtGencharge_LostFocus()
Dim y As Double, y1 As Double, y2 As Double
y1 = Val("0" & txtGencharge.Text) ' Protect against an empty control.
y2 = Val("0" & txtFranchise.Text) ' Protect against an empty control.
y = y1 + y2
txtGencorev.Text = CStr(y)
End Sub
ââââââââââââââââââââââââââââââââââââââââ
Private Sub txtFranchise_LostFocus()
Dim y As Double, y1 As Double, y2 As Double
y1 = Val("0" & txtGencharge.Text) ' Protect against an empty control.
y2 = Val("0" & txtFranchise.Text) ' Protect against an empty control.
y = y1 + y2
txtGencorev.Text = CStr(y)
End Sub
But perhaps better:
Code:
Private Sub Form_Load()
End Sub
ââââââââââââââââââââââââââââââââââââââââ
Private Sub txtGencharge_LostFocus()
txtGencorev.Text = CStr(CDbl("0" & txtGencharge.Text) + _
CDbl("0" & txtFranchise.Text))
End Sub
ââââââââââââââââââââââââââââââââââââââââ
Private Sub txtFranchise_LostFocus()
txtGencorev.Text = CStr(CDbl("0" & txtGencharge.Text) + _
CDbl("0" & txtFranchise.Text))
End Sub