Hi, i want some help on my VB game (school project).
My vb is 6.0 and i want do match image.

i want do 6 random pictures, if you can help me, tanks

Recommended Answers

All 6 Replies

You may follow these steps:

1. create the six pictures you want;
2. put 12 image or picture controls on your form;
3. use Randomize function to create the seed;
4. use Rnd function to get randomic numbers;
5. use LoadPicture method to load the images into controls.

You may know that Rnd function gets a Random number, and it can be the same number you already gave...
This way, if you want a tip, work with 12 numbers, one for each picture **control** - not for each image you create, right?

So, populate an array with these numbers, take care not to repeat each them.
(If you need assistance please type "www.google.com" in your browser address bar and make a little search for "how to generate distinct numbers with Rnd").

After this, you'll loop through each control in your form.
I suggest that you name controls with same name (I'll use imgFig for the example) and the images with a sequential integer, like "IMG1.BMP", "IMG2.BMP" and so on.

A loop will load any images you want.
See example:

'Consider the array variable vImgs contains 12 numbers, non-repeated, generated randomically
'You NEED to populate the array BEFORE you call this routine

Dim nCont as Integer

For nCont = 0 to 11
  'CONSIDER YOU NAME THE IMAGES IMG1.BMP, IMG2.BMP... AND ALL BE IN "C:\PASTA\" DIRECTORY
  'OR YOU MAY CHANGE THIS LINE TO POINT TO CORRECT IMAGE NAMES - DIRECTORY NAME
  If vImgs(nCont) > 6 then
    imgFig(nCont).Picture = LoadPicture("C:\PASTA\IMG" & vImgs(nCont) - 6 & ".BMP")
  Else
    imgFig(nCont).Picture = LoadPicture("C:\PASTA\IMG" & vImgs(nCont) & ".BMP")
  End If
Next

Note that code will show ALL pictures in screen...
You may use it for the beginning of the game, to quicly show images, and make it disappear again:

For nCont = 0 to 11
  imgFig(nCont).Picture = Nothing
Next

A little tip: if you work with Timer controls, the above codes will be excellent...

And for last, each time the user clicks on a image, use ONLY the line that load the image - this code

If vImgs(nCont) > 6 then
    imgFig(nCont).Picture = LoadPicture("C:\PASTA\IMG" & vImgs(nCont) - 6 & ".BMP")
  Else
    imgFig(nCont).Picture = LoadPicture("C:\PASTA\IMG" & vImgs(nCont) & ".BMP")
  End If

- to load certain image and use your imagination to make the control over that - the user matched the images, the user don't matched images, the user clicks twice on same image...


Good luck!
Sidnei

Hi Ra1sed,
If your problem is still not solved, download vbFun10 using Google. I hope this helps a lot.

Good Luck

hou to link the images from the images folder to the database

Please do not hijack others threads.

Please start your own thread for a new question.

@Kallurivenu, start a NEW and your OWN thread by clicking THIS link. You will not get any help from members by hijacking others threads.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.