下載/瀏覽

Download Report

Transcript 下載/瀏覽

計算機程式及實習
題目 : 南台飲料店結帳系統
南台科技大學
機械系車輛四甲
學號:49715092
姓名:徐正哲
老師:謝慶存
版面配置
屬性設定
數量
TextBoxnum1
TextBoxnum2
TextBoxnum3
TextBoxnum4
列出
ListBox1
金額
Label8
累計
Label9
價格
TextBoxPrice1
TextBoxPrice2
TextBoxPrice3
TextBoxPrice4
飲料
Label1 Label2
Label3 Label4
Label5 Label6
優惠方案
GroupBox1
RadioButton1
RadioButton2
RadioButton3
Button1
Button2




TextBoxPrice1
TextBoxPrice2
TextBoxPrice3
TextBoxPrice4




TextBoxnum1
TextBoxnum2
TextBoxnum3
TextBoxnum4
Text
Text
Text
Text
Text
Text
Text
Text
紅茶價格
綠茶價格
青茶價格
烏龍茶價格
紅茶數量
綠茶數量
青茶數量
烏龍茶數量
 RadioButton1
 RadioButton2
 RadioButton3
Text
Text
Text

 Button1
 Button2
Text
Text
老師*0.5
 ListBox1
南台學生*0.9
南台老師*0.8
教學認真的謝慶存
清除
總額
由程式控制
程式碼設計













Public Class Form1
Dim total, acctotal As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label8.Text = "$" & total & "元﹐"
Label9.Text = "累O計p : $" & acctotal & "元﹐"
Label8.Font = New Font("標D楷P¢體e", 45)
Label8.ForeColor = Color.Green
Label9.Font = New Font("標D楷P¢體e", 25)
Label9.ForeColor = Color.Blue
total = 0
acctotal = 0
End Sub
第2行定義總金額及累計金額的參數。












Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
TextBoxPrice1.Text = 10
TextBoxPrice2.Text = 10
TextBoxPrice3.Text = 25第2~9行為「清除」按鈕的歸零動作
TextBoxPrice4.Text = 15
TextBoxnum1.Text = 0
TextBoxnum2.Text = 0
TextBoxnum3.Text = 0
TextBoxnum4.Text = 0
total = 0
Label8.Text = "$" & total & "元﹐"
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

total = Val(TextBoxPrice1.Text) * Val(TextBoxnum1.Text) + Val(TextBoxPrice2.Text) * Val(TextBoxnum2.Text) + Val(TextBoxPrice3.Text) * Val(TextBoxnum3.Text) +
Val(TextBoxPrice4.Text) * Val(TextBoxnum4.Text)

If RadioButton1.Checked = True Then total = total * 0.9

If RadioButton2.Checked = True Then total = total * 0.8

If RadioButton3.Checked = True Then total = total * 0.5

Label8.Text = "$" & total & "元﹐"

acctotal = acctotal + total

Label9.Text = "累O計p:G$" & acctotal & "元﹐"

ListBox1.Items.Add(total & "~" & "紅茶" & TextBoxPrice1.Text & "*" & TextBoxnum1.Text & "綠茶" & TextBoxPrice2.Text & "*" & TextBoxnum2.Text & "奶茶" &
TextBoxPrice3.Text & "*" & TextBoxnum3.Text & "青茶" & TextBoxPrice4.Text & "*" & TextBoxnum4.Text)

End Sub

Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxPrice4.TextChanged

End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

acctotal = acctotal - (Val(ListBox1.SelectedItem))

ListBox1.Items.Remove(ListBox1.SelectedIndex)

Label9.Text = "累計p : $" & acctotal & "元﹐"

End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

End Sub

End Class