1、Form1: Private Sub Form_Load() Dim temp As Integer Randomize temp = Int(Rnd * 3) + 1 Form1.Picture = LoadPicture("C:\Users\Administrator\Desktop\打地鼠\picture" & temp & ".jpg") WindowsMediaPlayer1.URL = "C:\Users\Administrator\Desktop\打地鼠\Heaven's Devils.wma" End Sub Private Sub Label1_Click
2、) Form2.Show Form2.num = -1 Form1.Hide WindowsMediaPlayer1.URL = "" Open "C:\Users\Administrator\Desktop\打地鼠\primary.dat" For Append As #1 '写操作 Close #1 Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Append As #2 Close #2 Open "C:\Users\Administrator\Desktop\打地鼠\advanc
3、ed.dat" For Append As #3 Close #3 End Sub Private Sub Label2_Click() End End Sub Form2: Dim allnum As Integer, oknum As Integer '定义变化次数 打中次数 Public num As Integer '判别是否第一次开始游戏 Dim flags1 As Boolean '判别文件是否保存 Public flags As Boolean '判别是否播放声音 Private Sub countine_Click() pause.
4、Enabled = True Timer1.Enabled = True countine.Enabled = False WLXZ.Enabled = True End Sub Private Sub exit_Click() Dim X As Integer Dim tt As Integer X = MsgBox("是否真的退出?", vbYesNo, "退出游戏框") If X = 6 Then tt = MsgBox("退出游戏之前,是否保存", vbYesNo, "保存提示") If tt = 6 Then
5、 If flags1 = True Then End Else If Timer1.Interval = 1000 Then Open "C:\Users\Administrator\Desktop\打地鼠\primary.dat" For Append As #1 '写操作 Print #1, Text1.Text + " " + Format(Date, "
6、M/d/yy") Close #1 ElseIf Timer1.Interval = 500 Then Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Append As #2 Print #2, Text1.Text + " " + Format(Date, "M/d/yy")
7、 Close #2 Else Open "C:\Users\Administrator\Desktop\打地鼠\advanced.dat" For Append As #3 Print #3, Text1.Text + " " + Format(Date, "M/d/yy") Close #3 End If End If
8、 End If End End If End Sub Private Sub Form_Load() Form4.Check1.Value = 1 WindowsMediaPlayer1.Controls.stop countine.Enabled = False pause.Enabled = False WLXZ.Enabled = False Form5.Top = Form2.Top + 700 Form5.Left = Form2.Left flags1 = False flags = True End Sub Private Sub
9、help_Click() Form3.Show End Sub Private Sub new_game_Click() num = num + 1 Dim t As Integer If (num > 0) Then t = MsgBox("新游戏开始之前,是否保存", vbYesNo, "保存提示") If t = 6 Then flags1 = True If Timer1.Interval = 1000 Then Open "C:\Users\Administrator\
10、Desktop\打地鼠\primary.dat" For Append As #1 '写操作 Print #1, Text1.Text + " " + Format(Date, "M/d/yy") Close #1 ElseIf Timer1.Interval = 500 Then Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Append As #2
11、 Print #2, Text1.Text + " " + Format(Date, "M/d/yy") Close #2 Else Open "C:\Users\Administrator\Desktop\打地鼠\advanced.dat" For Append As #3 Print #3, Text1.Text + " " + Format(Date, "M/d/yy") Close #3
12、 End If End If End If Call Form_Load allnum = 0 '变化次数初始为0 oknum = 0 '打中次数初始为0 Timer1.Enabled = True pause.Enabled = True WLXZ.Enabled = True End Sub Private Sub options_Click() Timer1.Enabled = False Form4.Show WLXZ.Enabled = False countine.Enabled = True End Sub
13、 Private Sub pause_Click() Dim r, g, b As Integer Timer1.Enabled = False countine.Enabled = True pause.Enabled = False WLXZ.Enabled = False Form5.Top = Form2.Top + 700 Form5.Left = Form2.Left Form5.Show r = Rnd * 255 g = Rnd * 255 b = Rnd * 255 Form5.BackColor = RGB(r, g, b) End Sub Pr
14、ivate Sub Picture1_Click(Index As Integer) If Picture1(Index).Visible = True Then Picture1(Index).Picture = Src.Picture1.Picture '击晕图显示 If flags = True Then WindowsMediaPlayer1.Controls.play End If End If oknum = oknum + 1 '打中次数+1 End Sub Private Sub statistics
15、Click() Form5.Show WLXZ.Enabled = False countine.Enabled = True End Sub Private Sub record_Click() Form6.Show End Sub Private Sub Timer1_Timer() Dim I As Integer Text1.Text = oknum & "/" & allnum '打印得分 allnum = allnum + 1 '变化次数值+1 For I = 0 To 23 Picture1(I).Visible = False
16、 '地鼠消失 Picture1(I).Picture = Src.Picture2.Picture Next Randomize Picture1(Int(Rnd() * 23)).Visible = True '随机函数控制地鼠图片显示 End Sub Form4: Private Sub Check1_Click() If Check1.Value = 1 Then flags = True Else flags = False End If End Sub Private Sub Form_Loa
17、d() Option1.Value = True Check1.Value = 1 End Sub Private Sub Option1_Click() Form2.Timer1.Interval = 1000 '初级 End Sub Private Sub Option2_Click() Form2.Timer1.Interval = 500 '中级 End Sub Private Sub Option3_Click() Form2.Timer1.Interval = 250 '高级 End Sub Form5: Private Sub Form_L
18、ostFocus() Form5.Hide End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Form5.Hide End Sub Private Sub Timer1_Timer() '泡泡屏幕保护 Dim X, Y, r, g, b, radius X = Rnd * Form5.Width Y = Rnd * Form5.Height r = Rnd * 255 g = Rnd * 255 b = Rnd *
19、 255 radius = Rnd * 800 Form5.Circle (X, Y), radius, RGB(r, g, b) End Sub Private Sub Timer2_Timer() Form5.Cls End Sub Form6: Private Sub List1_Click() Text1.Text = "" If List1.Selected(0) = True Then Open "C:\Users\Administrator\Desktop\打地鼠\primary.dat" For Input As #1 Tex
20、t1.Text = Input(LOF(1), #1) Close #1 ElseIf List1.Selected(1) = True Then Text1.Text = "" ElseIf List1.Selected(2) = True Then Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Input As #2 Text1.Text = Input(LOF(2), #2) Close #2 ElseIf List1.Selected(3) = True Then Text1.Text = "" Else Open "C:\Users\Administrator\Desktop\打地鼠\advanced.dat" For Input As #3 Text1.Text = Input(LOF(3), #3) Close #3 End If End Sub






