Alright well i have started programming with the wonderful language of VB. And i am now making a memory game. And i ran into a problem. I don't know how to do it. I got the basic stuff down. Here is how it works. When the form loads up there is 16 yellow squares and when you click on one a flag comes up. Now you go and try to find the matching flag in one of the other 15 spaces. And there are a couple of problems that i am having. The first is that i can't get the flag to match up with the name below it ExFlag is America -- Name is Canada) and then another problem that i am having is that when the flags do match they don't dissapear. So here is a link and i posted the form image and here is the code.
Option Explicit
Const conMaxMatches As Integer = 8
Dim blnFirstTurn As Boolean
Dim intNumMatches As Integer
Dim intFirstPick As Integer
Dim Index As Integer
Dim strCountry As Integer
Dim i As Integer
lblFlagName(7).Caption = "Sierleon.bmp"
lblFlagName(15).Caption = "Sierleon.bmp"
End Function
Private Function set_up_blanks()
For i = 0 To 15
picFlag(i).Picture = LoadPicture("blank.bmp")
picFlag(i).Visible = True
picFlag(i).Enabled = True
Next i
End Function
Private Function swap_names()
Dim strName As String
Dim intSwap1 As Integer
Dim intSwap2 As Integer
Dim i As Integer
Randomize
For i = 0 To 15 'swap names 16 times
intSwap1 = Int(16 * Rnd) 'generate two random places
intSwap2 = Int(16 * Rnd) 'to swap
heheheh go kingarthur...er..code? or program? shizznits
Wombat
"I like to go to the schoolyard where i can watch the little kids jumping and screaming....but they dont know im using blanks"
"Before you set yourself on fire, remember to take off your shoes... nothing smells worse than burning rubber."
"They advertise that certain laundry detergents can take blood stains out of clothes, i say that if you have blood stains on your clothes, maybe your laundry is the least of your worries."
Sometimes when I'm driving around I see a sign that says, CAUTION: SMALL CHILDREN PLAYING. I slow down, and then it occurs to me: I'm not afraid of small children.
"My programs dont have bugs, they have random features" - MisianThrop
"The good thing about our ticket to the future is that it's always blank" - Trigun
Originally posted by alkatran sorry, guess I made a mistake, like it said in post, I made it up on the spot.. anyone see my error?? (its about 4 posts up)
If you read my post...it was nothing wrog with his code, it was he switching labels and pictureboxes....
Aight i see what the problem was with the names and the pictures. Man i can't belevie i didn't see that. Well i got that fixed and i got it where when you click the box the flag comes up and the name shows but one thing that I am having a lot of trouble with is making them dissappear after about 2 seconds. Any Ideas?
I have made that work. And I have attached a working sample. But don't use the code. Use it as a reference. That is the way you learn...
What I did, was making a "global" variable that holds the index of the picture selected. Then when you click a picture. The index of that picture is signed to a variable long (called toClose). Then a timer is enabled. The timer interval is set to 2000 (2sec). Then when the timer event occurs, it closes the picture.
Aight well i read over the code and i see how you got it to work. That is pretty cool man. But i noticed a couple of errors. First when you click the picture box the name also comes up below it(i made an adjustment to where the name's visibility = false and then when you click the pic box it shows up) but i can't make it go away. So that is one problem. And then also there are two labels on the side called lblPick1 and lblPick2. And lblPick1 has to display the first pick and then lblPick2 has to display the second pick. Below i got the newley furnished memory. I just added the visibility = false to the lblFlagName. Aight
OK, I made the Label disapear after 2sec, and you can see in the first label on the right the name of the flag you clicked on. But I don't want to do the whole game for you, so you have to do the second Label on your own...
You will have to use an if sentence to see if you already have clicked an other one...post if you have more problems...but I think this is so simple so I think you can do tjis on your own...
I can see what you are meaning, and I do think some of the same thoughts...but I don't think that it's necessary post your thoughts like that....if you would tell him to learn VB before making games, then tell him then and don't make fun of those who are not as good as you. Because I know that you are not a newbie anymore, but you once was. So try to be kind to the neebies, or don't post at all...that is my thoughts about this case...