1 / 12

期末 作業

期末 作業. 姓名 : 呂治懋 學號 : 4A115060 班級 : 車輛一甲 指導老師 : 謝慶存. STUSTcafe . 結帳 系統. 製作 一個 咖啡 店 的結帳 系統 想做一個可以像 7-11 貨物計算的結帳系統 會列出 幾點幾分賣出一杯咖啡. 解題分析. 上網和翻書 找出系統的時間 在計算商品數量 和價錢. 程式實作 方法. 結帳按鈕 要能夠記算全部的金額 並且連折扣都算進去 要 能夠 列出時間 清 空按鈕要 能夠把剛剛輸入的資料清空掉 優惠選像只能選 一個 然後改變優惠變數值. 程式碼. Public Class Form1

kibo-nelson
Télécharger la présentation

期末 作業

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 期末作業 姓名:呂治懋 學號:4A115060 班級:車輛一甲 指導老師:謝慶存

  2. STUSTcafe.結帳系統 • 製作一個咖啡店的結帳系統 • 想做一個可以像7-11貨物計算的結帳系統 • 會列出幾點幾分賣出一杯咖啡

  3. 解題分析 • 上網和翻書 找出系統的時間 • 在計算商品數量 和價錢

  4. 程式實作方法 • 結帳按鈕 要能夠記算全部的金額 並且連折扣都算進去 • 要能夠列出時間 • 清空按鈕要能夠把剛剛輸入的資料清空掉 • 優惠選像只能選一個 然後改變優惠變數值

  5. 程式碼 • Public Class Form1 • Dim price, discount As Single • Dim bu(35), chak1, chak2 As Boolean • Dim buS(35), lis As String • Dim s, cost(12), cost2(9), price1, mach As Integer • Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load • chak1 = False • chak2 = False • cost(1) = 20 '綠茶 • End Sub • 做變數宣告和價錢商品的初始化

  6. 程式碼 • Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated • Label14.Text = Label14.Text & " - $" & cost(1) • Label13.Text = Label13.Text & " - $" & cost(2) • Label12.Text = Label12.Text & " - $" & cost(3) • Label11.Text = Label11.Text & " - $" & cost(4) • Label10.Text = Label10.Text & " - $" & cost(5) • Label9.Text = Label9.Text & " - $" & cost(6) • End Sub • 顯示出現在的價錢

  7. 程式碼 • Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load • cost(1) = 35 • cost(2) = 35 • cost(3) = 45 • cost(4) = 45 • cost(5) = 45 • cost(6) = 45 • End Sub • 每杯咖啡的價錢設定

  8. 程式碼 • Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click • price = TextBox1.Text * cost(1) + TextBox2.Text * cost(2) + TextBox3.Text * cost(3) + _ • TextBox4.Text * cost(4) + TextBox5.Text * cost(5) + TextBox6.Text * cost(6) • Call a() • Select Case True • Case RadioButton1.Checked • discount = 1 • Case RadioButton2.Checked • discount = 0.9 • Case RadioButton3.Checked • discount = 0.8 • Case Else • discount = 1 • End Select • Label8.Text = Fix(price * discount) • End Sub • 結帳按鈕 計算總金額 和 優惠

  9. 程式碼 • Sub a() • Dim lis As String • ListBox1.Items.Clear() • If TextBox1.Text Then • lis = Label1.Text & "($" & cost(1) & ") / " & TextBox1.Text & "杯M " & Now • ListBox1.Items.Add(lis) • End If • A副程式用來列出買賣清單

  10. 程式碼 • Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click • ListBox1.Items.Clear() • TextBox1.Text = 0 • TextBox2.Text = 0 • TextBox3.Text = 0 • TextBox4.Text = 0 • TextBox5.Text = 0 • TextBox6.Text = 0 • Label8.Text = "金÷額B" • End Sub • 清除按鈕

  11. 心得感想 • 第一次做VB 沒想到這麼難 因為以前沒用過 所以做的時候遇到很多問題 找同學幫忙 雖然做了很久不過總算做出來了。

  12. 參考範例 • Visual Basic2008 教學範本 古頤蓁著 • Visual Basic2008程式設計樂活學 鄧文淵著 • Visual Basic2010 程式設計 許華清著 • https://www.google.com/

More Related