04-14-2008, 12:37 AM
This isn't in QuickBasic it is actually in Visual Basic but I am hoping someone can help me. It a memory game where you try and select the like cards. I am having trouble making sure the user has selected one card and if the next card he/she selects is either a match or not a match here is the code.
I was thinking that using blnFirstTurn (value can be true or false) which is automatically set to true on the form load will be set to false on the click of the card and then when the user clicks the next card (this is part im having a bit of trouble with) it sets it to false and resets the card. which I think would look something like. This is without all the other code btw.
something like the above (which I don't think will work. Any help is much appreciated.
Code:
Option Explicit
Dim blnFirstTurn As Boolean
Dim intNumMatches As Integer
Private Sub Form_Load()
  blnFirstTurn = True
  intNumMatches = 0
 Â
  Call set_up_blanks
  Call load_names
  Call swap_names
 Â
  frmMemory.Top = (Screen.Height - frmMemory.Height) / 2
  frmMemory.Left = (Screen.Width - frmMemory.Width) / 2
 Â
End Sub
Private Sub imgCard_Click(Index As Integer)
  imgCard(Index).Picture = LoadPicture(lblCardName(Index))
 Â
End Sub
Private Sub load_names()
  lblCardName(0).Caption = "I:\vb\memory\alienware_new_logo01.jpg"
  lblCardName(8).Caption = "I:\vb\memory\alienware_new_logo01.jpg"
 Â
  lblCardName(1).Caption = "I:\vb\memory\dell.gif"
  lblCardName(9).Caption = "I:\vb\memory\dell.gif"
 Â
  lblCardName(2).Caption = "I:\vb\memory\hp-logo.jpg"
  lblCardName(10).Caption = "I:\vb\memory\hp-logo.jpg"
 Â
  lblCardName(3).Caption = "I:\vb\memory\logo-gateway.gif"
  lblCardName(11).Caption = "I:\vb\memory\logo-gateway.gif"
 Â
  lblCardName(4).Caption = "I:\vb\memory\intel-logo.jpg"
  lblCardName(12).Caption = "I:\vb\memory\intel-logo.jpg"
 Â
  lblCardName(5).Caption = "I:\vb\memory\amd.gif"
  lblCardName(13).Caption = "I:\vb\memory\amd.gif"
 Â
  lblCardName(6).Caption = "I:\vb\memory\nvidia_logo.jpg"
  lblCardName(14).Caption = "I:\vb\memory\nvidia_logo.jpg"
 Â
  lblCardName(7).Caption = "I:\vb\memory\ati_logo_1204_rgb1.jpg"
  lblCardName(15).Caption = "I:\vb\memory\ati_logo_1204_rgb1.jpg"
 Â
End Sub
Private Sub set_up_blanks()
  Dim intX As Integer
 Â
  For intX = 0 To 15
    imgCard(intX).Picture = LoadPicture("I:\vb\memory\mego_blank.jpg")
  Next intX
 Â
End Sub
Public Sub swap_names()
  Dim I As Integer
  Dim strName As String
  Dim intSwap1 As Integer
  Dim intSwap2 As Integer
 Â
  Randomize
  For I = 1 To 16
    intSwap1 = Int(16 * Rnd)
    intSwap2 = Int(16 * Rnd)
   Â
    strName = lblCardName(intSwap1).Caption
    lblCardName(intSwap1).Caption = lblCardName(intSwap2).Caption
    lblCardName(intSwap2).Caption = strName
  Next I
 Â
End Sub
I was thinking that using blnFirstTurn (value can be true or false) which is automatically set to true on the form load will be set to false on the click of the card and then when the user clicks the next card (this is part im having a bit of trouble with) it sets it to false and resets the card. which I think would look something like. This is without all the other code btw.
Code:
blnFirstTurn = true
Private Sub imgCard_Click(Index As Integer)
  count = 1
  if count = 1 then
  blnFirstTurn = false
  end if
  if cardname = cardname then
  match is true
  else
  match is not true
  count = count - 1
end sub
something like the above (which I don't think will work. Any help is much appreciated.