當前位置:編程學習大全網 - 編程語言 - vb課程設計~~~代碼已有求解釋~~~~越詳細越好~~大神們來啊~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vb課程設計~~~代碼已有求解釋~~~~越詳細越好~~大神們來啊~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Dim bln1 As Boolean

Dim bln2 As Boolean

Dim bln3 As Boolean

Dim bln4 As Boolean

Dim blnstoptuzi As Boolean

Dim blnstopwugui As Boolean

Dim int1 As Integer

Dim int2 As Integer

Dim int3 As Integer

Dim m As Integer

Dim n As Integer

Dim k As Integer '上面都是聲明變量

Private Sub HScroll1_change() 'change當控件內容發送變化時的事件

k = CInt(HScroll1.Value) ‘cint 取整函數將內容賦予給變量k

Picture1.SetFocus '將焦點轉到Picture控件

End Sub

Private Sub command1_Click()

Call 開始 '調用“開始”過程

End Sub

Private Sub menuaboutjog_Click() '這個應該是菜單的吧...

Dim intresponse As Integer

intresponse = MsgBox("版本1.01," & Chr(10) & Chr(13) & "歡迎多多指教!", 48, "關於龜兔賽跑") 'msgbox 函數彈出內容並賦予給變量intresponse

End Sub

Private Sub menuesc_Click()

Dim intresponse As Integer

intresponse = MsgBox("確定退出?", 289, "註意")

If intresponse = 1 Then '當用戶按“確定”時卸載FORM1窗體

Unload Form1

End If

End Sub

Private Sub menuselffile_Click()

Shell "E:\5 遊戲設計\26 龜兔賽跑\readme.txt", 1 'shell函數調用txt文本

End Sub

Private Sub menustart_Click()

Call 開始

End Sub

Private Sub Picture1_keypress(keyascii As Integer) 'picture的鍵盤事件

Dim blnxidongtuzi As Boolean

Dim intresponse As Integer

Dim a As Integer

If blnstoptuzi = True Then 'if語句 當blnstoptuzi為真時

If bln1 Or bln2 = False Then '當bln1 或 bln2 為假時

bln1 = False

bln2 = False “bln1和Bln2為假

End If

End If

If Image2.Left >= Picture1.Width - Image2.Width Then '當image2的left屬性大於或等於picture的寬度減image2的寬度時

blnstoptuzi = True 'blnstoptuzi 為真

End If

If keyascii = 97 Then bln1 = True '當用戶按下chr(97)時 bln1等於真,這裏的97是ascii值我也記不住那麽多妳自己可以查 chr(ascii的值)就可以看到是哪個鍵了

If keyascii = 115 Then bln2 = True

If bln1 = False Then bln2 = False

If bln1 And bln2 = True Then

blnxidongtuzi = True

If blnxidongtuzi = True Then

Image2.Left = Image2.Left + k 'image2的left在'image2的left基礎上加上變量k

blnxidongtuzi = False

bln1 = False

bln2 = False

End If

If (keyascii = 97 Or keyascii = 115) And int1 <= 7 Then

Image2.Left = 0

intresponse = MsgBox("兔選手搶跑,重來!", 16, "犯規!")

If intresponse = 1 Then

Timer1.Enabled = False

Label5.Caption = ""

End If

End If

End If

End Sub

Private Sub form_keypress(keyascii As Integer)

Dim blnxidongwugui As Boolean

Dim intresponse As Integer

If blnstopwugui = True Then

If bln3 Or bln4 = False Then

bln3 = False

bln4 = False

End If

End If

If Image3.Left >= Picture2.Width - Image3.Width Then

blnstopwugui = True

End If

If keyascii = 59 Then bln3 = True

If keyascii = 39 Then bln4 = True

If bln3 = False Then bln4 = False

If bln3 And bln4 = True Then

blnxidongwugui = True

If blnxidongwugui = True Then

Image3.Left = Image3.Left + k

blnxidongwugui = False

bln3 = False

bln4 = False

End If

If (keyascii = 59 Or 39) And int1 <= 7 Then

Image3.Left = 0

intresponse = MsgBox("龜選手搶跑,重來!", 16, "犯規!")

If intresponse = 1 Then

Timer1.Enabled = False

Label5.Caption = ""

End If

End If

End If

End Sub

Private Sub Timer1_Timer()

int1 = int1 + 1

If intl <= 6 And int1 Mod 2 = 0 Then

Label5.Caption = "預備!"

End If

If int1 <= 6 And int1 Mod 2 = 1 Then

Label5.Caption = ""

End If

If int1 = 7 Then

Label5.Caption = "開始!"

End If

If int1 >= 8 Then

Label5.Caption = ""

Timer1.Enabled = False

Timer2.Enabled = True

Timer3.Enabled = True

End If

End Sub

Private Sub Timer2_Timer()

Dim a As Integer

Dim b As Integer

a = int2 / 60

b = int2 Mod 60

int2 = int2 + 1

If int2 < 60 Then

If int2 < 10 Then

Text1.Text = "00:00:0" & int2

Else

Text1.Text = "00:00:" & int2

End If

Else

If b < 10 Then

Text1.Text = "00:00:0" & a

Else

Text1.Text = "00:00:" & a

End If

End If

If blnstoptuzi = True Then

Timer2.Enabled = False

Timer4.Enabled = True

m = int2

End If

End Sub

Private Sub Timer3_Timer()

Dim c As Integer

Dim d As Integer

c = int3 / 60

d = int3 Mod 60

int3 = int3 + 1

If int3 < 60 Then

If int3 < 10 Then

Text2.Text = "00:00:0" & int3

Else

Text2.Text = "00:00:" & int3

End If

Else

If d < 10 Then

Text2.Text = "00:00:0" & c

Else

Text2.Text = "00:00:" & c

End If

End If

If blnstopwugui = True Then

Timer3.Enabled = False

Timer4.Enabled = True

n = int3

End If

End Sub

Private Sub 開始()

If int1 <> 0 Or int2 <> 0 Then

Image2.Left = 0

Image3.Left = 0

Timer1.Enabled = False

Timer2.Enabled = False

Timer3.Enabled = False

Text1.Text = "00:00:00"

Text2.Text = "00:00:00"

Label5.Caption = ""

int1 = 0

int2 = 0

int3 = 0

m = 0

n = 0

blnstoptuzi = False

blnstopwugui = False

Picture1.SetFocus

End If

Timer1.Enabled = True

End Sub

Private Sub Timer4_Timer()

Dim blnjs As Boolean

If m <> 0 And n <> 0 Then

blnjs = True

End If

If blnjs = True Then

If m < n Then

intresponse = MsgBox("兔選手贏了!", 48, "龜兔賽跑")

intresponse = 1

Timer2.Enabled = False

Timer3.Enabled = False

int2 = 0

int3 = 0

blnjs = False

End If

If m > n Then

intresponse = MsgBox("龜選手贏了!", 48, "龜兔賽跑")

intresponse = 1

Timer2.Enabled = False

Timer3.Enabled = False

int2 = 0

int3 = 0

blnjs = False

End If

End If

If blnjs = False Then

Timer4.Enabled = False

End If

End Sub

rme 意思基本上都差不多妳可以自己看下吧

  • 上一篇:怎樣才能進入微軟?
  • 下一篇:比賽獎品買什麽好?
  • copyright 2024編程學習大全網