谁有用vb做的连连看

 我来答
qw708965245
2011-08-28
知道答主
回答量:3
采纳率:0%
帮助的人:8.7万
展开全部
Dim b(0 To 8)
Dim m, k, n

Private Sub Command1_Click()
a = "012345678"
For i = 0 To 8
Randomize
temp = Int(Rnd * Len(a) + 1)
Label1.Caption = 40
If i <= 1 Then
b(Mid(a, temp, 1)) = "red"
ElseIf i > 1 And i <= 3 Then
b(Mid(a, temp, 1)) = "blue"
ElseIf i > 3 And i <= 5 Then
b(Mid(a, temp, 1)) = "green"
ElseIf i > 5 And i <= 7 Then
b(Mid(a, temp, 1)) = "cyan"
ElseIf i = 8 Then
b(Mid(a, temp, 1)) = "black"
End If
a = Replace(a, Mid(a, temp, 1), "")
Next
Timer1.Enabled = True
For i = 0 To 8
Text1(i).Visible = True
Next
End Sub

Private Sub Form_Load()
n = "1"
For i = 0 To 8
Text1(i).Visible = False
Text1(i).BackColor = vbWhite
Text1(i).Enabled = True

Next
End Sub

Private Sub Text1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, y As Single)
If n = 1 Then
m = Index
n = 2
Else
k = Index
Timer2.Enabled = True
End If
If b(Index) = "red" Then
Text1(Index).BackColor = vbRed
ElseIf b(Index) = "blue" Then
Text1(Index).BackColor = vbBlue
ElseIf b(Index) = "green" Then
Text1(Index).BackColor = vbGreen
ElseIf b(Index) = "cyan" Then
Text1(Index).BackColor = vbCyan
ElseIf b(Index) = "black" Then
Text1(Index).BackColor = vbBlack
End If
End Sub

Private Sub Timer1_Timer()
If Label1.Caption <> 0 Then Label1.Caption = Label1.Caption - 1
If Label1.Caption = 0 Then
d = MsgBox("是否重新开始", vbYesNo, "失败")
If d = vbYes Then
Call Form_Load
Call Command1_Click
Else
Timer1.Enabled = False
End If
End If

For d = 0 To 8
If Controls("text1")(d).Enabled = False Then e = e + 1
Next
If e = 8 Then
d = MsgBox("是否重新开始", vbYesNo, "成功")

If d = vbYes Then
e = 0
Call Form_Load
Call Command1_Click
Else
Timer1.Enabled = False
End If

End If
End Sub

Private Sub Timer2_Timer()
If b(m) = b(k) Then
Text1(m).Enabled = False
Text1(k).Enabled = False
Else
Text1(m).BackColor = vbWhite
Text1(k).BackColor = vbWhite
End If
n = 1
Timer2.Enabled = False

End Sub
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式