'this assumes there's 10 command buttons
dim names(0 to 4)
dim combutton(0 to 9) as string
dim turned as byte
dim messups as integer 'how many times the player misses
dim matches as integer 'how many matches the player has
private sub form_load
dim a as byte
'set the names to whatever, add more if you want, just have 2x
'as many command buttons
names(0) = "whatever0"
names(1) = "whatever1"
names(2) = "whatever2"
names(3) = "whatever3"
names(4) = "whatever4"
do until a = 10
'picks a random number between 0 and 9
b = int(rnd *10)
'This checks if the commandbutton has been assigned a name
'yet, int(a/2) makes 2 command buttons get same thing so you
'can have matches
if combutton(b) = "" then combutton(b) = names(int(a/2)): a = a + 1
loop
end sub
Private sub Commands_click(index as integer)
'Have an array of command buttons named commands
'this sub is for when a button is clicked
Commands(index).caption = ComButton(index)
'if nothing else is turned, then remember this button
If Turned = 0 then turned = Index
'if something else is flipped, check if its the same, if it is, disable both
If Turned > 0 and Commands(index).caption = Commands(Turned).caption then Commands(index).enabled = false: Commands(Turned).enabled = false:matches = matches + 1
'if its not, set them back to normal
If Turned > 0 and not Commands(index).caption = Commands(Turned).caption then Commands(index).caption = "": Commands(turned).caption = "": turned = 0:messups = messups + 1
'now, to see if he's won or lost..
'put the number of possibilities here, if its more then 5
if matches => 5 then msgbox "you win!": end
'how many times they can get it wrong.. you might want more then 5
if messups > 5 then msgbox "you lose!: end
end sub