jogo em visualbasic

firmas2010

Power Member
boas para todos,

estou a realizar um trabalho de informatica no excel em visualbasic, este trabalho é um jogo aonde supostamente temos de encontrar e fazer pares, ora estou a deparar me com algumas dificuldades, as imagens encontram-se todas no excel com nomes de gra1 a gra36 pois trata-se de um array com 6 colunas e 6 linhas, e já nos é fornecido alguns dados no editor do visual basic, que sao estes:

Código:
Option Explicit

Type TpJogo
  fig(1 To 6, 1 To 6) As String
  LastRow As Integer
  LastCol As Integer
  Score As Integer
End Type
  
Public jogo As TpJogo

Sub MyWait(ByVal wt As Single)
 Dim t As Single
 t = Timer
 Do
 Loop Until Timer - t > wt
End Sub

Sub Coloca_Pos(ByRef jogo As TpJogo, ByVal r As Integer, ByVal c As Integer)
Dim hc As Single, hf As Single, wc As Single, wf As Single
Dim nf As String
On Error GoTo fim
With Range("tabuleiro")
 hc = .Cells(r, c).Height
 wc = .Cells(r, c).Width
 nf = jogo.fig(r, c)
 hf = ActiveSheet.Shapes(nf).Height
 wf = ActiveSheet.Shapes(nf).Width
 ActiveSheet.Shapes(nf).Top = .Cells(r, c).Top + (hc - hf) / 2
 ActiveSheet.Shapes(nf).Left = .Cells(r, c).Left + (wc - wf) / 2
End With
fim:
End Sub
Sub Esconde(ByRef jogo As TpJogo, ByVal r As Integer, ByRef c As Integer)
With jogo
 ActiveSheet.Shapes(.fig(r, c)).Visible = False
End With
DoEvents
End Sub
Sub Mostra(ByRef jogo As TpJogo, ByVal r As Integer, ByRef c As Integer)
With jogo
 ActiveSheet.Shapes(.fig(r, c)).Visible = True
End With
DoEvents
End Sub
Function Visivel(ByRef jogo As TpJogo, ByVal r As Integer, ByRef c As Integer) As Boolean
With jogo
 Visivel = ActiveSheet.Shapes(.fig(r, c)).Visible
End With
End Function
ora agora eu queria colocar isto a baralhar as imagens dentro do array, alguem me pode dar uma ajuda? explicando isso , sou um nabo a isto e preciso mesmo de alguma ajuda

obrigado
 
Última edição pelo moderador:
sim isso eu ja percebi, o meu problema é a nivel de associar um botao ao codigo
e colocar a baralhar

Código:
 Sub baralhar(tabuleiro)
Dim fig As Integer, i As Integer, j As Integer, max As Integer
 For i = 1 To 6
  j(i) = i
Next
 max = 36
 j = Int(1 + max * Rnd)
 fig(i) = fig(j)
 max = max - 1
 Next
 baralhar = fig

que que aqui tá errado? ou que que ta bem?LOL

que que me falta para conseguir finalizar o processo de baralhar em condiçoes?

obrigado
 
Back
Topo