用记事本把下面的代码保存到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
四个文件放在同一个文件夹中,进入VB环境后,打开cro.vbp (这个是VB的工程文件),打开后工程文件后,Form1.frm(窗体文件)就可以打开了。
VB中的主要文件类型如下
扩展名 描述
.bas 基本模块
.cls 类模块
.ctl 用户控件文件
.ctx 用户控件的二进制文件
.dca 活动的设计器的高速缓存
.ddf 打包和展开向导 CAB 信息文件
.dep 打包和展开向导从属文件
.dob ActiveX 文档窗体文件
.dox ActiveX 文档二进制窗体文件
.dsr 活动的设计器文件
.dsx 活动的设计器的二进制文件
.dws 部署向导脚本文件
.frm 窗体文件
.frx 二进制窗体文件
.log 加载错误的日志文件
.oca 控件类型库缓存文件
.pag 属性页文件
.pgx 二进制属性页文件
.res 资源文件
.tlb 远程自动化类型库文件
.vbg Visual Basic 组工程文件
.vbl 控件许可文件
.vbp Visual Basic 工程文件
.vbr 远程自动化注册文件
.vbw Visual Basic 工程工作空间文件
.vbz 向导发射文件
.wct WebClass HTML 模板
Private Sub Command1_Click()
Open "D:\abc\" & Text1.Text & ".txt" For Output As #1
Print #1, Text2.Text
Close #1
End Sub