您可能會喜歡......

2017年9月20日 星期三

Visual Basic 華氏轉攝氏及攝氏轉華氏數值轉換

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim h, s As Single
        h = InputBox("請輸入華氏溫度", "華氏轉攝氏")
        s = 5 / 9 * (h - 32)
        MsgBox("攝氏溫度為" & s, , "華氏轉攝氏")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim h, s As Single
        s = InputBox("請輸入攝氏溫度", "攝氏轉華氏")
        h = 9 * s / 5 + 32
        MsgBox("華氏溫度為" & h, , "攝氏轉華氏")
    End Sub
End Class

沒有留言:

張貼留言