利用VB做一个连连看游戏 我需要完整的VB代码 要确保能用的 希望能发给我 谢谢大神 5
2个回答
2015-07-10
展开全部
'添加picturebox控件数组,ProgressBar控件和2个timer控件
'搜集自网络,在d:\新建文件夹下,放10个图片0个图片(名字分别为 1.jpg、2.jpg、3.jpg、4.jpg、5.jpg.....10.jpg)
Dim i As Integer '要建立的图片框个数
Dim aa As Integer
Dim gg As Integer
Dim ss As Integer
Dim jj As Integer, hh As Integer '保存声明窗体的宽度和长度
Dim tt As Integer '声明时间变量
Dim ff As Integer
Dim nn As Integer '声明图片框已经隐藏的变量
Dim kk As String
Dim pp As Integer
Dim j, uu As Integer
Dim tf As Integer, kl As Integer
Dim oo As Integer
Dim vv As Integer
Dim rr, mm As Integer
Dim cc As Integer
Dim ee, qq As Integer
Dim ll As Integer
Dim ww As Integer
Dim a As Integer
Dim mm1, nn1 As Integer
Dim ty, yt As Integer
Dim strnn As String
Dim strmm As String
Private Sub Form_Load()
On Error GoTo Myerror
Me.Visible = False
pp = 0
kk = ".jpg"
ProgressBar1.Max = 200
Picture1(0).Visible = False
For i = 1 To 100
pp = pp + 1
If pp = 11 Then
pp = 1
End If
gg = gg + 1
If gg = 10 Then
ss = ss + Picture1(0).Height + 50
gg = 0
aa = Picture1(0).Left
hh = ss + 800
Else
aa = aa + Picture1(0).Width + 50
jj = aa + Picture1(0).Width + 120
End If
Load Picture1(i)
Picture1(i).Picture = LoadPicture("d:\新建文件夹\" & pp & kk)
Picture1(i).Width = Picture1(0).Width
Picture1(i).Height = Picture1(0).Height
Picture1(i).Left = aa
Picture1(i).Top = ss
Picture1(i).AutoRedraw = True
Picture1(i).Visible = True
If i = 100 Then
Picture1(100).Left = Picture1(0).Left
Picture1(100).Top = Picture1(0).Top
Picture1(100).Height = Picture1(0).Height
Picture1(100).Width = Picture1(0).Width
Picture1(100).Visible = True
Picture1(100).Picture = LoadPicture("d:\新建文件夹\" & pp & kk)
End If
Next i
Me.Width = jj
Me.Height = hh - 150
ProgressBar1.Height = 255
ProgressBar1.Width = Me.Width
ProgressBar1.Top = hh - 800
ProgressBar1.Left = 0
Timer1.Interval = 500
Timer2.Interval = 100
Timer1.Enabled = False
Randomize Timer2
tt = 200
ProgressBar1.Value = tt
Exit Sub
Myerror:
MsgBox "D:\新建文件夹 文件夹下加载图片", vbOKOnly, "错误对话框“"
End
End Sub
Private Sub Picture1_Click(Index As Integer)
nn = 0
pp = 0
Select Case Index
Case Index
oo = oo + 1
If oo = 1 Then
ee = Index
For vv = 1 To 100
pp = pp + 1
If pp = 11 Then
pp = 1
End If
If vv = Index Then
rr = vv
tf = pp
End If
Next
End If
If oo = 2 Then
qq = Index
For vv = 1 To 100
pp = pp + 1
If pp = 11 Then
pp = 1
End If
If vv = Index Then
mm = vv
kl = pp
End If
Next vv
oo = 0
End If
If tf = kl Then
If ee <> qq Then
Picture1(rr).Visible = False
Picture1(mm).Visible = False
tf = 0
kl = 0
End If
End If
End Select
For i = 0 To 99
If Picture1(i).Visible = False Then
nn = nn + 1
End If
If nn = 100 Then
MsgBox "恭喜!!! 过关了!"
Timer1.Enabled = False
End If
Next i
End Sub
Private Sub Timer1_Timer()
tt = tt - 1
ProgressBar1.Value = tt
If tt = 0 Then
ff = MsgBox("哈哈 您已经输了", vbOKOnly, "关闭对话框")
If ff = 1 Then
End
End If
End If
End Sub
Private Sub Timer2_Timer()
a = a + 1
If a = 100 Then
Timer2.Enabled = False
Timer1.Enabled = True
Me.Show
End If
ll = Int(Rnd * 101)
ww = Int(Rnd * 101)
strnn = strnn + "," + Str(ll)
strmm = strmm + "," + Str(ww)
If InStr(ll, strnn) = 0 And InStr(ww, strmm) = 0 Then
If ll <> 0 And ww <> 0 Then
If ll <> ww Then
mm1 = Picture1(ll).Left
nn1 = Picture1(ll).Top
ty = Picture1(ww).Left
yt = Picture1(ww).Top
Picture1(ll).Left = ty
Picture1(ll).Top = yt
Picture1(ww).Top = nn1
Picture1(ww).Left = mm1
End If
End If
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询