Thursday, 2 November 2017

Fahrenheit to Celsius and Celsius to Fahrenheit


Private Sub BtnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnShow.Click
        'The conversion equation for Celsius to Fahrenheit-- F = C x 1.8 + 32
        'Fahrenheit to Celsius-- C = (F - 32) / 1.8

        If RadioButton1.Checked = True Then
            Dim a As Decimal
            a = CDec(TextBoxTemprature.Text - 32) / 1.8
            MessageBox.Show(TextBoxTemprature.Text & " Farenheit is equal to " & Decimal.ToSByte(a) & " Celsius", "Fahrenheit to Celsius")
        ElseIf RadioButton2.Checked = True Then
            Dim b As Decimal
            b = (TextBoxTemprature.Text - 1.8) + 32
            MessageBox.Show(TextBoxTemprature.Text & " Celsius is equal to " & Decimal.ToSByte(b) & " Farenheit", "Celsius to Fahrenheit")
        End If
    End Sub
End Class

https://www.youtube.com/channel/UCKLRUr6U5OFeu7FLOpQ-FSw/videos

0 comments

Post a Comment