ned two independent Sub procedures: one to convert a temperature from fahrenheit to Celsius and the other to convert fahrenheit to celsius.
1
Expert's answer
2012-11-12T08:18:26-0500
Dim celcius As Decimal = 0D Dim fahrenheit As Decimal = 0D Dim f As Decimal Dim c As Decimal celcius = Decimal.Parse(celTextBox.Text) fahrenheit = Decimal.Parse(fahTextBox.Text) 'celcius to farenheit formula: If celcius > 0 Then #039; Notice the conversion from our decimal value to String #039; Before placing it into the textbox fahTextBox.Text = Convert.ToString(c * 1.8 + 32) Else MessageBox.Show("Enter celcius greater than 0") End If 'farenheit to celcius formula: If fahrenheit > 0 Then #039; Again we convert from a decimal value to a string before #039; placing into textbox celTextBox.Text = Convert.ToString(f - 32 / 1.8) Else MessageBox.Show("Enter fahrenheit greater than 0") End If
Comments
Leave a comment