用记事本把下面的代码保存到Form1.Frm文件中。然后用VB打开,试试吧。
===========
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "打地鼠"
ClientHeight = 2175
ClientLeft = 45
ClientTop = 330
ClientWidth = 1860
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2175
ScaleWidth = 1860
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "开始"
Height = 375
Left = 0
TabIndex = 9
Top = 1800
Width = 615
End
Begin VB.Timer Timer1
Interval = 500
Left = 120
Top = 1920
End
Begin VB.PictureBox Picture1
Height = 615
Index = 8
Left = 1200
ScaleHeight = 555
ScaleWidth = 555
TabIndex = 8
Top = 1200
Width = 615
End
Begin VB.PictureBox Picture1
Height = 615
Index = 7
Left = 600
ScaleHeight = 555
ScaleWidth = 555
TabIndex = 7
Top = 1200
Width = 615
End
Begin VB.PictureBox Picture1
Height = 615
Index = 6
Left = 0
ScaleHeight = 555
ScaleWidth = 555
TabIndex = 6
Top = 1200
Width = 615
End
Begin VB.PictureBox Picture1
Height = 615
Index = 5
Left = 1200
ScaleHeight = 555
ScaleWidth = 555
TabIndex = 5
Top = 600
Width = 615
End
Begin VB.PictureBox Picture1
Height = 615
Index = 4
Left = 600
ScaleHeight = 555
ScaleWidth = 555
TabIndex = 4
Top = 600
Width = 615
End
Begin VB.PictureBox Picture1
Height = 615
Index = 3
Left = 0
ScaleHeight = 555
ScaleWidth = 555
TabIndex = 3
Top = 600
Width = 615
End
Begin VB.PictureBox Picture1
Height = 615
Index = 2
Left = 1200
ScaleHeight = 555
ScaleWidth = 555
TabIndex = 2
Top = 0
Width = 615
End
Begin VB.PictureBox Picture1
Height = 615
Index = 1
Left = 600
ScaleHeight = 555
ScaleWidth = 555
TabIndex = 1
Top = 0
Width = 615
End
Begin VB.PictureBox Picture1
Height = 615
Index = 0
Left = 0
ScaleHeight = 555
ScaleWidth = 555
TabIndex = 0
Top = 0
Width = 615
End
Begin VB.Label Label1
AutoSize = -1 'True
Height = 180
Left = 720
TabIndex = 10
Top = 1920
Width = 90
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer, t As Integer
Private Sub Command1_Click()
On Error GoTo hErr
t = 2 * InputBox("请设置游戏时间,单位为秒:", , 60)
Caption = 0
Timer1.Enabled = True
Command1.Enabled = False
hErr:
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Randomize
For Each p In Picture1
p.FontName = "arial"
p.FontSize = 30
Next
End Sub
Private Sub Picture1_Click(Index As Integer)
If Index = i Then Caption = Caption + 1: t = t + 1: Timer1_Timer
End Sub
Private Sub Timer1_Timer()
For Each p In Picture1
p.Cls
Next
i = Int(Rnd * 9)
Picture1(i).Print i + 1
t = t - 1
Label1.Caption = "倒计时:" & Int(t / 2)
If t = 0 Then Timer1.Enabled = False: MsgBox "游戏结束,您共打到" & Caption & "次地鼠": i = -1: Command1.Enabled = True
End Sub
有RMB吗?
作器源代码想用分解决啊?还5分。。。
那程序员都饿死街头了!