My program consists of two textboxes performing a farenheit to celsius conversion using the textbox change event. If I type, for instance, 2 in a textbox I get 1.9999. This is annoying because I can't type in large numbers like 212 because the value immediately changes to 1.9999. I think the reason it is happening because it is recursing. When I type in a value it gets calculated back and forth...back and forth by the two subs until it loses its value.
Code:
Private Sub txt_C_Change()
Dim C, F, txtF, txtC As Double
If IsNumeric(txt_C.Text) Then
txtC = txt_C.Text
F = 1.8 * txtC + 32
txt_F.Text = CStr(F)
Else: txt_F.Text = ""
txt_C.Text = ""
End If
End Sub
Private Sub txt_F_Change()
Dim C, F, txtF, txtC As Double
If IsNumeric(txt_F.Text) Then
txtF = txt_F.Text
C = (txtF - 32) / 1.8
txt_C.Text = CStr(C)
Else: txt_C.Text = ""
txt_F.Text = ""
End If
End Sub