日韩明星配对机.ppt

上传人:本田雅阁 文档编号:3208895 上传时间:2019-07-31 格式:PPT 页数:24 大小:4.21MB
返回 下载 相关 举报
日韩明星配对机.ppt_第1页
第1页 / 共24页
日韩明星配对机.ppt_第2页
第2页 / 共24页
日韩明星配对机.ppt_第3页
第3页 / 共24页
日韩明星配对机.ppt_第4页
第4页 / 共24页
日韩明星配对机.ppt_第5页
第5页 / 共24页
点击查看更多>>
资源描述

《日韩明星配对机.ppt》由会员分享,可在线阅读,更多相关《日韩明星配对机.ppt(24页珍藏版)》请在三一文库上搜索。

1、日韓明星配對機,班級:自控一甲 姓名:王郁涵 學號:49912006,目錄,簡介 題目說明 程式版面介紹 程式碼設計步驟 程式碼說明 成品操作方式 結語,簡介,學習製作程序。 Label、PictureBox、DomainUpDown、的使用方法。 技巧要領。 程式代碼的涵義。,遊戲說明,設計一個類似拉霸 系統,將喜歡的韓 星配對,當選重相 同女星時,獎金便 會加倍,投注金額 越大,中獎機率便 會增加。,程式版面介紹,將背景改為喜歡的明星照片,Label1,DomainUpDown,Labe2,PictureBox1,PictureBox2,PictureBox3,Button1,程式碼設計步

2、驟,先點選表單,進入寫程式畫面,將以下指 令輸入在裡頭,並把所有的表單那的物件 改名稱(在Name修改與程式碼符合的名 稱),填寫完後,在開始偵錯是否有錯誤。,程式碼設計,Public Class Form1 宣告p(0)p(3)的PictureBox陣列,可存放用來存放0.jpg3.jpg 其中p(0)不使用,p(1)p(3)代表三個拉霸圖示 Dim p(3) As PictureBox 宣告num(0)num(3)的整數陣列,用來存放03的數值 其中num(0)不使用 Dim num(3) As Integer Dim t As Integer 宣告t用來計算Timer1共執行幾次,表單載

3、入時執行Form1_Load事件處理程序 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 使表單無法被調整大小 Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink picBtn.Image = New Bitmap(“up.jpg“) 使picBtn顯示up.jpg 使載入的圖片隨picBtn大小伸縮 picBtn.SizeMode = PictureBoxSizeMode

4、.StretchImage p(1) = pic1 將pic1指定給p(1) p(2) = pic2 將pic2指定給p(2) p(3) = pic3 將pic3指定給p(3), 使用迴圈使pic1pic3顯示0.jpg圖 For i As Integer = 1 To p.GetUpperBound(0) p(i).Image = Image.FromFile(“0.jpg“) p(i).SizeMode = PictureBoxSizeMode.Zoom Next Timer1.Interval = 200 使Timer1計時器每0.2秒執行一次 lblSum.Text = 300 可投注

5、的總數量lblSum為300 End Sub, 按下picBtn鈕時會執行picBtn_Click事件處理函式 Private Sub picBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picBtn.Click 判斷 投注量nudQty.Value是否大於 0 且 投注量nudQty.Value是否大於可投注總數量lblSum.Text If nudQty.Value 0 And nudQty.Value = lblSum.Text Then Timer1.Enabled = Tru

6、e 計時器Timer1啟動 可投注量減掉本次的的投注題 lblSum.Text = Val(lblSum.Text) - nudQty.Value nudQty.Enabled = False 無法投注 picBtn.Image = New Bitmap(“down.jpg“) 使picBtn,顯示down.jpg picBtn.Enabled = False picBtn圖片按鈕失效 Else 若投注量小於0且投注量大於可投注的總數量 MsgBox(“投注有誤“) End If End Sub 當Timer1啟動時,每0.1秒皆會執行Timer1_Tick事件處理程序一次 Private S

7、ub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim r As New Random 建立亂數物件r 使用迴圈讓pic1pic3每次執行皆亂數的方式顯示0.jpg3.jpg For i As Integer = 1 To p.GetUpperBound(0) num(i) = r.Next(0, 4) 產生 03 的亂數並指定給 n(1)n(3), 使pic1pic3以亂數的方式顯示 0.jpg3.jpg p(i).Image = Image.From

8、File(num(i).ToString & “.jpg“) Next t += 1 當計時器執行20次時,即馬上判斷是否中獎 If t = 20 Then Timer1.Enabled = False 計時器Timer1停止 nudQty.Enabled = True 可以開始投注 picBtn.Enabled = True picBtn圖形按鈕可啟用 當num(1)=0且num(2)=0且num(3)=0表示pic1pic3三個圖示皆是荔枝 If num(1) = 0 And num(2) = 0 And num(3) = 0 Then lblSum.Text = (Val(lblSum.

9、Text) + (nudQty.Value * 5).ToString MsgBox(“中獎了! 投注量*10“), 當num(1)=1且num(2)=1且num(3)=1表示pic1pic3三個圖示皆是星星 ElseIf num(1) = 1 And num(2) = 1 And num(3) = 1 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 10).ToString MsgBox(“中獎了! 投注量*15“) 當num(1)=2且num(2)=2且num(3)=2表示pic1pic3三個圖示皆是西瓜 ElseIf num(

10、1) = 2 And num(2) = 2 And num(3) = 2 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 15).ToString MsgBox(“中獎了! 投注量*15“) 當num(1)=3且num(2)=3且num(3)=3表示pic1pic3三個圖示皆是BAR,ElseIf num(1) = 3 And num(2) = 3 And num(3) = 3 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 20).ToString MsgBox(“中獎

11、了! 投注量*20“) ElseIf num(1) = 0 And num(2) = 0 And num(3) = 1 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 2).ToString MsgBox(“中獎了! 投注量*2“) ElseIf num(1) = 1 And num(2) = 0 And num(3) = 0 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 2).ToString MsgBox(“中獎了! 投注量*2“) ElseIf num(1) =

12、1 And num(2) = 1 And num(3) = 2 Then,lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 4).ToString MsgBox(“中獎了! 投注量*4“) ElseIf num(1) = 2 And num(2) = 1 And num(3) = 1 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 4).ToString MsgBox(“中獎了! 投注量*4“) ElseIf num(1) = 2 And num(2) = 2 And num(3)

13、= 1 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 4).ToString MsgBox(“中獎了! 投注量*4“),ElseIf num(1) = 1 And num(2) = 2 And num(3) = 2 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 4).ToString MsgBox(“中獎了! 投注量*4“) ElseIf num(1) = 2 And num(2) = 2 And num(3) = 3 Then lblSum.Text = (Val(

14、lblSum.Text) + (nudQty.Value * 5).ToString MsgBox(“中獎了! 投注量*5“) ElseIf num(1) = 3 And num(2) = 2 And num(3) = 2 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 5).ToString MsgBox(“中獎了! 投注量*5“),ElseIf num(1) = 0 And num(2) = 3 And num(3) = 3 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value

15、 * 7).ToString MsgBox(“中獎了! 投注量*7“) ElseIf num(1) = 3 And num(2) = 3 And num(3) = 0 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 7).ToString MsgBox(“中獎了! 投注量*7“) ElseIf num(1) = 3 And num(2) = 3 And num(3) = 1 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * -5).ToString MsgBox(“不幸的!

16、 倒扣投注量*-5“),ElseIf num(1) = 1 And num(2) = 3 And num(3) = 3 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * -5).ToString MsgBox(“不幸的! 倒扣投注量*-5“) ElseIf num(1) = 3 And num(2) = 3 And num(3) = 2 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 8).ToString MsgBox(“中獎了! 投注量*8“) ElseIf num(1

17、) = 2 And num(2) = 3 And num(3) = 3 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 8).ToString MsgBox(“中獎了! 投注量*8“) ElseIf num(1) = 0 And num(2) = 0 And num(3) = 2 Then,lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * -2).ToString MsgBox(“不幸的! 倒扣投注量*-2“) ElseIf num(1) = 2 And num(2) = 0 And

18、 num(3) = 0 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * -2).ToString MsgBox(“不幸的! 倒扣投注量*-2“) ElseIf num(1) = 0 And num(2) = 2 And num(3) = 2 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 5).ToString MsgBox(“中獎了! 投注量*5“) ElseIf num(1) = 2 And num(2) = 2 And num(3) = 0 Then lblSum.

19、Text = (Val(lblSum.Text) + (nudQty.Value * 5).ToString MsgBox(“中獎了! 投注量*5“),ElseIf num(1) = 3 And num(2) = 0 And num(3) = 0 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 6).ToString MsgBox(“中獎了! 投注量*6“) ElseIf num(1) = 0 And num(2) = 0 And num(3) = 3 Then lblSum.Text = (Val(lblSum.Text) + (

20、nudQty.Value * 6).ToString MsgBox(“中獎了! 投注量*6“) ElseIf num(1) = 0 And num(2) = 1 And num(3) = 1 Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 6).ToString MsgBox(“中獎了! 投注量*6“) ElseIf num(1) = 1 And num(2) = 1 And num(3) = 0,Then lblSum.Text = (Val(lblSum.Text) + (nudQty.Value * 6).ToString MsgBox(“中獎了! 投注量*6“) End If picBtn.Image = New Bitmap(“up.jpg“) 使picBtn顯示up.jpg t = 0 End If End Sub End Class,成品操作方式,獎金加倍,獎金倒扣,結語,到了第二學期,我們更加了解VB了,編寫的程式也越來越難,像這次的期末報告、丙級試題,都讓我深陷難關,不是偵錯不出來,不然就是連程式都打不出來。越有難度,就讓我們更有好奇心,當偵錯成功那刻就會知道,前面花的時間都會是值得的,就跟這次的拉霸機一樣,希望每次都可以中獎!,謝謝指教,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1