我已经好几年没有在 Visual Basic 中编程了,但是我有这个代码可以将温度从华氏温度转换为摄氏温度。问题是当您在其中一个文本框中输入数字时,您会得到重复的数字并且值不正确。我认为这与手柄有关,但我在这里很迷茫,有什么想法吗?
Public Class MainForm
Private Sub FahrenheitTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FahrenheitTextBox.TextChanged
CelciusTextBox.Text = 5 / 9 * (Val(FahrenheitTextBox.Text) - 32)
End Sub
Private Sub CelciusTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CelciusTextBox.TextChanged
FahrenheitTextBox.Text = (9 / 5 * (Val(CelciusTextBox.Text)) + 32)
End Sub
End Class