2019年1月24日 星期四
2019年1月10日 星期四
2019年1月9日 星期三
蜜香紅茶訂購程式
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim num, sum, i As Integer
num = TextBox1.Text
If num > 0 Then
Select Case num
Case Is >= 100
sum = num * 500 * 0.8
Case Is >= 50
sum = num * 500 * 0.9
Case Is > 25
sum = num * 500 * 0.95
Case 1 To 25
sum = num * 500
End Select
Else
MsgBox("重新輸入數量", 32, "錯誤訊息")
Label5.Text = ""
End If
Label4.Text = sum & "元"
i = sum \ 2000
Select Case i
Case Is < 0
Label5.Text = ""
Case Is = 0
Label5.Text = "無"
Case Is < 5
Label5.Text = "抵用券" & i * 200 & "元"
Case Is >= 5
Label5.Text = "抵用券1000元"
End Select
End Sub
End Class
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim num, sum, i As Integer
num = TextBox1.Text
If num > 0 Then
Select Case num
Case Is >= 100
sum = num * 500 * 0.8
Case Is >= 50
sum = num * 500 * 0.9
Case Is > 25
sum = num * 500 * 0.95
Case 1 To 25
sum = num * 500
End Select
Else
MsgBox("重新輸入數量", 32, "錯誤訊息")
Label5.Text = ""
End If
Label4.Text = sum & "元"
i = sum \ 2000
Select Case i
Case Is < 0
Label5.Text = ""
Case Is = 0
Label5.Text = "無"
Case Is < 5
Label5.Text = "抵用券" & i * 200 & "元"
Case Is >= 5
Label5.Text = "抵用券1000元"
End Select
End Sub
End Class
簡易成績統計
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim score, sum, max, m, n As Integer
Dim scorelist As String = "我輸入的分數分別為:"
m = InputBox("我總共要輸入幾個分數?")
For i = 1 To m
score = InputBox("請輸入第" & i & "科成績")
scorelist &= score & ","
sum = sum + score
If score > max Then max = score
If score < 60 Then n += 1
If i = m Then scorelist = Strings.Left(scorelist, Len(scorelist) - 1)
Next
TextBox1.Text = scorelist & ControlChars.CrLf
If CheckBox1.Checked Then TextBox1.Text =
TextBox1.Text & "總分為:" & sum & ControlChars.CrLf
If CheckBox2.Checked Then TextBox1.Text =
TextBox1.Text & "最高分數為:" & max & ControlChars.CrLf
If CheckBox3.Checked Then TextBox1.Text =
TextBox1.Text & "不及格科數:" & n & ControlChars.CrLf
End Sub
End Class
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim score, sum, max, m, n As Integer
Dim scorelist As String = "我輸入的分數分別為:"
m = InputBox("我總共要輸入幾個分數?")
For i = 1 To m
score = InputBox("請輸入第" & i & "科成績")
scorelist &= score & ","
sum = sum + score
If score > max Then max = score
If score < 60 Then n += 1
If i = m Then scorelist = Strings.Left(scorelist, Len(scorelist) - 1)
Next
TextBox1.Text = scorelist & ControlChars.CrLf
If CheckBox1.Checked Then TextBox1.Text =
TextBox1.Text & "總分為:" & sum & ControlChars.CrLf
If CheckBox2.Checked Then TextBox1.Text =
TextBox1.Text & "最高分數為:" & max & ControlChars.CrLf
If CheckBox3.Checked Then TextBox1.Text =
TextBox1.Text & "不及格科數:" & n & ControlChars.CrLf
End Sub
End Class
訂閱:
文章 (Atom)