偷偷放點暑假,不可以無所事事 學點東西最好得方法就是動手做做 針對上一篇 夏天-濕度與不快指數 寫了計算機 就當作練習,程式碼如下 --------------------------------------------------------------- Private Sub Command1_Click() If Text1.Text = "" Then MsgBox "請輸入攝氏氣溫", 16, "氣溫" Exit Sub End If If Text2.Text = "" Then MsgBox "請輸入濕度", 16, "濕度" Exit Sub End If A = Text1.Text B = Text2.Text Text3.Text = 0.81 * A + 0.01 * B * (0.99 * A - 14.3) + 46.3 End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Then Exit Sub If KeyAscii = 46 Then Exit Sub If KeyAscii = 8 Then Exit Sub KeyAscii = 0 End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Then Exit Sub If KeyAscii = 46 Then Exit Sub If KeyAscii = 8 Then Exit Sub KeyAscii = 0 End Sub ------------------------------------------------------------