PROBLEMA COM VARIAS CONDICOES

USUARIO.EXCLUIDOS 03/08/2007 15:43:14
#229372
Olá gente .... tÃÂ' fazendo um campo minado .... axo q o jeito q estou fazendo pode dar certo...

Eu fiz um array de 81 botões ..... onde fika o Index (1) no canto inferior e o 81 no canto superior esquerdo... sendo assim há 9 na vertical e 9 na horizontal.... fiz todas as condições de acordo na estrutura da interface (botões)...

a ideia é ... sortei alguns botões pra q tenham FontSize = 20
caso se o usuario apertar esse botão a bomba explode ... caso seja algum perto dele .... então a variavel soma + 1 e passa pro caption do botão.... mas nada ocorre qd eu faço isso...




Private Sub Command1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Sorteio As Byte
Dim Contar As Byte

Contar = 0

Do While Contar <> 10
Randomize
Sorteio = Int((81 * Rnd) + 1)
Command1(Sorteio).FontSize = 20
Contar = Contar + 1
Loop


Dim CaminhoTNT As String
Dim CaminhoAviso As String
Dim variavel As Integer
Dim Lateral As CommandButton

variavel = 0
CaminhoTNT = App.Path & "\" & "TNT.bmp"
CaminhoAviso = App.Path & "\" & "Aviso.bmp"

Timer1.Enabled = True
Timer1.Interval = 1000

For Each Lateral In Command1

If Button = 1 Then

If Lateral.Left = Command1(1).Left And Index <> 1 Then 'Sem Direita
If Index > 8 Then
If Command1(Index - 8).FontSize = 20 Then 'Diagonal Inferior Esquerda
Command1(Index).Caption = variavel + 1
End If
End If
If Command1(Index).FontSize = 20 Then
Set Command1(Index).Picture = LoadPicture(CaminhoTNT)
End If
If Index < 73 Then
If Command1(Index + 9).FontSize = 20 Then 'Cima
Command1(Index).Caption = variavel + 1
End If
End If
If Index > 9 Then
If Command1(Index - 9).FontSize = 20 Then 'Baixo
Command1(Index).Caption = variavel + 1
End If
End If
If Index <> 81 Then
If Command1(Index + 1).FontSize = 20 Then 'Lado Esquerdo
Command1(Index).Caption = variavel + 1
End If
End If
If Index < 72 Then
If Command1(Index + 10).FontSize = 20 Then 'Diagonal Superior Esquerda
Command1(Index).Caption = variavel + 1
End If
End If
End If
'-----------------------------------------------------------------------
If Lateral.Left = Command1(9).Left Then 'Sem Esquerda
If Index > 10 Then
If Command1(Index - 10).FontSize = 20 Then 'Diagonal Inferior Direita
Command1(Index).Caption = variavel + 1
End If
End If
If Index <= 73 Then
If Command1(Index + 8).FontSize = 20 Then 'Diagonal Superior Direita
Command1(Index).Caption = variavel + 1
End If
End If
If Command1(Index).FontSize = 20 Then
Set Command1(Index).Picture = LoadPicture(CaminhoTNT)
End If
If Index < 73 Then
If Command1(Index + 9).FontSize = 20 Then 'Cima
Command1(Index).Caption = variavel + 1
End If
End If
If Index > 9 Then
If Command1(Index - 9).FontSize = 20 Then 'Baixo
Command1(Index).Caption = variavel + 1
End If
End If
If Command1(Index - 1).FontSize = 20 Then ' Lado Direito
Command1(Index).Caption = variavel + 1
End If
End If
'---------------------------------------------------------------------------
If Index >= 73 And Index <= 81 Then 'Sem superiores
If Command1(Index - 8).FontSize = 20 Then 'Diagonal Inferior Esquerda
Command1(Index).Caption = variavel + 1
End If
If Command1(Index - 10).FontSize = 20 Then 'Diagonal Inferior Direita
Command1(Index).Caption = variavel + 1
End If
If Command1(Index - 9).FontSize = 20 Then 'Baixo
Command1(Index).Caption = variavel + 1
End If
If Index <> 81 Then
If Command1(Index + 1).FontSize = 20 Then 'Lado Esquerdo
Command1(Index).Caption = variavel + 1
End If
End If
If Command1(Index - 1).FontSize = 20 Then ' Lado Direito
Command1(Index).Caption = variavel + 1
End If
End If
'---------------------------------------------------------------------------
If Index >= 1 And Index <= 9 Then 'Sem Inferiores
If Command1(Index + 8).FontSize = 20 Then 'Diagonal Superior Direita
Command1(Index).Caption = variavel + 1
End If
If Command1(Index + 1).FontSize = 20 Then 'Lado Esquerdo
Command1(Index).Caption = variavel + 1
End If
If Command1(Index - 1).FontSize = 20 Then ' Lado Direito
Command1(Index).Caption = variavel + 1
End If
If Command1(Index + 10).FontSize = 20 Then 'Diagonal Superior Esquerda
Command1(Index).Caption = variavel + 1
End If
If Command1(Index + 9).FontSize = 20 Then 'Cima
Command1(Index).Caption = variavel + 1
End If
End If
'------------------------------------------------------------------------------
If Not Index > 1 And Not Index >= 73 And Not Index <= 91 And Not Lateral.Left = Command1(9).Left And Not Lateral.Left = Command1(1).Left Then

If Command1(Index).FontSize = 20 Then
Set Command1(Index).Picture = LoadPicture(CaminhoTNT)
End If
If Command1(Index + 9).FontSize = 20 Then 'Cima
Command1(Index).Caption = variavel + 1
End If
If Command1(Index - 9).FontSize = 20 Then 'Baixo
Command1(Index).Caption = variavel + 1
End If
If Command1(Index + 1).FontSize = 20 Then 'Lado Esquerdo
Command1(Index).Caption = variavel + 1
End If
If Command1(Index - 1).FontSize = 20 Then ' Lado Direito
Command1(Index).Caption = variavel + 1
End If
If Command1(Index + 10).FontSize = 20 Then 'Diagonal Superior Esquerda
Command1(Index).Caption = variavel + 1
End If
If Command1(Index - 10).FontSize = 20 Then 'Diagonal Inferior Direita
Command1(Index).Caption = variavel + 1
End If
If Command1(Index + 8).FontSize = 20 Then 'Diagonal Superior Direita
Command1(Index).Caption = variavel + 1
End If
If Command1(Index - 8).FontSize = 20 Then 'Diagonal Inferior Esquerda
Command1(Index).Caption = variavel + 1
End If
End If

If Button = 2 Then 'Se Botão for direito
Set Command1(Index).Picture = LoadPicture(CaminhoAviso)
End If

End If
Next
End Sub



Obrigado à todos
HARRY.POTTER 03/08/2007 15:51:58
#229377
Resposta escolhida
Pára! Esse é o método lusitano!!!

Use recursividade que isso tudo ai sai em 10 linhas.
Tópico encerrado , respostas não são mais permitidas