用電 2010.9.27
用電 2010.9.27
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim use_power As Integer
Dim pay As Single
pay = 0
If IsNumeric(TextBox1.Text) Then
use_power = Val(TextBox1.Text)
If use_power <= 110 Then
pay = use_power * 2.1
ElseIf use_power >= 111 And use_power <= 330 Then
pay = 110 * 2.1 + (use_power - 110) * 3.23
ElseIf use_power >= 331 And use_power <= 500 Then
pay = 110 * 2.1 + (330 - 110) * 3.23 + (use_power - 330) * 4.05
ElseIf use_power >= 501 And use_power <= 700 Then
pay = 110 * 2.1 + (330 - 110) * 3.23 + (500 - 330) * 4.05 + (use_power - 500) * 4.51
ElseIf use_power >= 701 Then
pay = 110 * 2.1 + (330 - 110) * 3.23 + (500 - 330) * 4.05 + (700 - 500) * 4.51 + (use_power - 500) * 5.1
End If
If CheckBox1.Checked Then
pay = pay * 1.15
Label2.BackColor = Color.Red
Else
Label2.BackColor = Color.Empty
End If
Label2.Text = "電費" & pay.ToString & "元"
Else
Label2.Text = "輸入度數資料錯誤"
TextBox1.Clear()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
Dim use_power As Integer
Dim pay As Single
pay = 0
If IsNumeric(TextBox1.Text) Then
use_power = Val(TextBox1.Text)
If use_power <= 110 Then
pay = use_power * 2.1
ElseIf use_power >= 111 And use_power <= 330 Then
pay = 110 * 2.1 + (use_power - 110) * 3.23
ElseIf use_power >= 331 And use_power <= 500 Then
pay = 110 * 2.1 + (330 - 110) * 3.23 + (use_power - 330) * 4.05
ElseIf use_power >= 501 And use_power <= 700 Then
pay = 110 * 2.1 + (330 - 110) * 3.23 + (500 - 330) * 4.05 + (use_power - 500) * 4.51
ElseIf use_power >= 701 Then
pay = 110 * 2.1 + (330 - 110) * 3.23 + (500 - 330) * 4.05 + (700 - 500) * 4.51 + (use_power - 500) * 5.1
End If
If CheckBox1.Checked Then
pay = pay * 1.15
Label2.BackColor = Color.Red
Else
Label2.BackColor = Color.Empty
End If
Label2.Text = "電費" & pay.ToString & "元"
Else
Label2.Text = "輸入度數資料錯誤"
TextBox1.Clear()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
這個論壇的權限:
您 無法 在這個版面回復文章