Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, x Select Case x Case Is < 40 n = 2.2 * x Case Is >= 40 And x <= 100 n = 3 * x Case Is > 100 n = 3.5 * x End Select Print #2, n + 30 Close Close End End Sub
Private Sub Form_Load() '電費算法為:電錶每月租金30元, '用電在40度之內,每度2.2元,40 '度至100度,每度3元,超過100度,每度3.5元。 Me.Hide Dim sum As Integer Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, n sum = 0 Select Case n Case Is < 40 sum = n * 2.2 + 30 Case Is > 100 sum = n * 3.5 + 30 Case Else sum = n * 3 + 30 End Select Print #2, sum Close Close End End Sub
Dim num As Long
回覆刪除Dim already As Boolean
Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Input #1, num
Close #1
already = False
If already = False And num < 40 Then
num = num * 2.2
already = True
End If
If already = False And num = 40 Or num = 100 Or (num < 100 And 40 < num) Then
num = num * 3
already = True
End If
If already = False And num > 100 Then
num = num * 3.5
already = True
End If
Open App.Path & "\out.txt" For Output As #1
Print #1, num + 30
Close #1
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, x
Select Case x
Case Is < 40
n = 2.2 * x
Case Is >= 40 And x <= 100
n = 3 * x
Case Is > 100
n = 3.5 * x
End Select
Print #2, n + 30
Close
Close
End
End Sub
Private Sub Form_Load()
回覆刪除'電費算法為:電錶每月租金30元,
'用電在40度之內,每度2.2元,40
'度至100度,每度3元,超過100度,每度3.5元。
Me.Hide
Dim sum As Integer
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, n
sum = 0
Select Case n
Case Is < 40
sum = n * 2.2 + 30
Case Is > 100
sum = n * 3.5 + 30
Case Else
sum = n * 3 + 30
End Select
Print #2, sum
Close
Close
End
End Sub