自動收銀機


設計一程式製作一收銀機自動找零

自行完成紅字??????????部分之運算式

下載表單設計檔()

[物件安排]

 

 

 

Dim tot, ic, ct, t500, t100, t50, t10, t5, t1
 Private Sub cmdcls_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcls.Click '按清除程序
  txttot.Text = ""
  txtic.Text = ""
  txtc.Text = ""
  lbl500show.Text = ""
  lbl100show.Text = ""
  lbl50show.Text = ""
  lbl10show.Text = ""
  lbl5show.Text= ""
  lbl1show.Text = ""
 End Sub

 Private Sub cmdend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdend.Click
  End
 End Sub

 Private Sub cmdrun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrun.Click
  Dim tot As Single, ic As Single, ct As Single
  tot = Val(txttot.Text) '將總價文字方塊內容設為數值
  ic = Val(txtic.Text) '將收現金文字方塊內容設為數值
  ct = ic - tot '應找零錢
  txtc.Text = Str(ct) '顯示找零錢

   If ct >= 500 Then '若找零錢大於等於500元
    t500=1     '500元張數加1
    ct=ct-500 '找零錢減500元
   End If

   Do While ct >= 100 '若找零錢大於等於100元進迴圈
    ???????????? '100元張數加1, 將此行敘述填於第1格
    ???????????? '找零錢減100元, 將此行敘述填於第2格
   Loop

   If ct >= 50 Then '處理50元
    ???????????? '50元張數加1, 將此行敘述填於第3格
    ???????????? '找零錢減50元, 將此行敘述填於第4格
   End If

   Do While ct >= 10 '處理10元
    ???????????? '10元張數加1, 將此行敘述填於第5格
    ???????????? '找零錢減10元, 將此行敘述填於第6格
   Loop

   If ct >= 5 Then '處理5元
    ???????????? '5元張數加1, 將此行敘述填於第7格
    ???????????? '找零錢減5元, 將此行敘述填於第8格
   End If

   Do While ct >= 1 '處理1元
    ???????????? '1元張數加1, 將此行敘述填於第9格
    ???????????? '找零錢減1元, 將此行敘述填於第10格
   Loop

  lbl500show.Text = Str(t500) '顯示500元張數
  lbl100show.Text = Str(t100) '顯示100元張數
  lbl50show.Text = Str(t50) '顯示50元張數
  lbl10show.Text = Str(t10) '顯示10元張數
  lbl5show.Text = Str(t5) '顯示5元張數
  lbl1show.Text = Str(t1) '顯示1元張數

 End Sub