谢谢大家捧场!!!
下面是单击按钮时所用的函数,写出来的程序都比较复杂,不知道大家有没有什么好办法?
Public Function try(ByVal t As Integer, ByVal m As Integer)
Dim k As Integer
k = t
If t - 10 > 0 Then
If Command1(t - 10).Visible = True Then
Command1(t - 10).Visible = False
m = m + 1
If Label1(t - 10).Caption = "0" Then
Label1(t - 10).Caption = ""
k = t - 10
m = try(k, m)
End If
End If
End If
If t + 10 < 101 Then
If Command1(t + 10).Visible = True Then
Command1(t + 10).Visible = False
m = m + 1
If Label1(t + 10).Caption = "0" Then
Label1(t + 10).Caption = ""
k = t + 10
m = try(k, m)
End If
End If
End If
If t + 9 < 101 And (t + 9) Mod 10 <> 0 Then
If Command1(t + 9).Visible = True Then
Command1(t + 9).Visible = False
m = m + 1
If Label1(t + 9).Caption = "0" Then
Label1(t + 9).Caption = ""
k = t + 9
m = try(k, m)
End If
End If
End If
If t - 9 > 0 And (t - 9) Mod 10 <> 1 Then
If Command1(t - 9).Visible = True Then
Command1(t - 9).Visible = False
m = m + 1
If Label1(t - 9).Caption = "0" Then
Label1(t - 9).Caption = ""
k = t - 9
m = try(k, m)
End If
End If
End If
If t + 1 < 101 And (t + 1) Mod 10 <> 1 Then
If Command1(t + 1).Visible = True Then
Command1(t + 1).Visible = False
m = m + 1
If Label1(t + 1).Caption = "0" Then
Label1(t + 1).Caption = ""
k = t + 1
m = try(k, m)
End If
End If
End If
If t - 1 > 0 And (t - 1) Mod 10 <> 0 Then
If Command1(t - 1).Visible = True Then
Command1(t - 1).Visible = False
m = m + 1
If Label1(t - 1).Caption = "0" Then
Label1(t - 1).Caption = ""
k = t - 1
m = try(k, m)
End If
End If
End If
If t - 11 > 0 And (t - 11) Mod 10 <> 0 Then
If Command1(t - 11).Visible = True Then
Command1(t - 11).Visible = False
m = m + 1
If Label1(t - 11).Caption = "0" Then
Label1(t - 11).Caption = ""
k = t - 11
m = try(k, m)
End If
End If
End If
If t + 11 < 101 And (t + 11) Mod 10 <> 1 Then
If Command1(t + 11).Visible = True Then
Command1(t + 11).Visible = False
m = m + 1
If Label1(t + 11).Caption = "0" Then
Label1(t + 11).Caption = ""
k = t + 11
m = try(k, m)
End If
End If
End If
try = m
End Function