- 最後登錄
- 2022-6-10
- 在線時間
- 0 小時
- 註冊時間
- 2015-1-5
- 閱讀權限
- 95
- 精華
- 0
- UID
- 8553804
- 帖子
- 1
- 積分
- 1003 點
- 潛水值
- 13750 米
| 本帖最後由 darkjack 於 2018-1-6 05:59 PM 編輯
請問如果想要把下列每個熱量的數值直接總和在一個TEXTBOX 內請問要怎麼寫程式碼?
以下附件截圖為的目前執行出來的程式檔
以下是目前程式碼
- Public Class Form1
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim clickedCount = 0
- If Button1.Tag <> Nothing Then
- Int32.TryParse(Button1.Tag.ToString(), clickedCount)
- End If
- clickedCount += 1
- DoSomethingAccordingToClickedCount(clickedCount)
- Button1.Tag = clickedCount
- End Sub
- Private Sub DoSomethingAccordingToClickedCount(clickedCount As Integer)
- 'Todo:
- If clickedCount = 1 Then
- Randomize()
- Select Case Int((3) * Rnd())
- Case Is = 0
- Label1.Text = "麵 350大卡"
- Case Is = 1
- Label1.Text = "飯 370大卡"
- Case Is = 2
- Label1.Text = "水餃 400大卡"
- End Select
- End If
- If clickedCount = 2 Then
- Randomize()
- Select Case Int((3) * Rnd())
- Case Is = 0
- Label2.Text = "空心菜 150大卡"
- Case Is = 1
- Label2.Text = "湯匙菜 160大卡"
- Case Is = 2
- Label2.Text = "高麗菜 180大卡"
- End Select
- End If
- If clickedCount = 3 Then
- Randomize()
- Select Case Int((3) * Rnd())
- Case Is = 0
- Label3.Text = "蔥爆牛肉 250大卡"
- Case Is = 1
- Label3.Text = "炸排骨 280大卡"
- Case Is = 2
- Label3.Text = "三杯雞 260大卡"
- End Select
- End If
- If clickedCount = 4 Then
- Randomize()
- Select Case Int((3) * Rnd())
- Case Is = 0
- Label4.Text = "涼拌黃瓜 180大卡"
- Case Is = 1
- Label4.Text = "皮蛋豆腐 190大卡"
- Case Is = 2
- Label4.Text = "海澤皮 150大卡"
- End Select
- End If
- If clickedCount = 5 Then
- Randomize()
- Select Case Int((3) * Rnd())
- Case Is = 0
- Label5.Text = "南瓜湯 250大卡"
- Case Is = 1
- Label5.Text = "玉米濃湯 230大卡"
- Case Is = 2
- Label5.Text = "紫菜蛋花湯 150大卡"
- End Select
- End If
- End Sub
- End Class
複製代碼
小弟真的不知道該如何修改程式碼,跪求大大解答,很急~~謝謝
... |
附件: 你需要登錄才可以下載或查看附件。沒有帳號?註冊 |