By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

Visual basic To make a random image

P: 4
Is there any one who can help me to make a game .This game have to create with visual basic 2005 and it is like there are three images and one by one is appeared and disappeared. Our objective is to try to click fast these images as much as we can. Moreover if we click one image we will get score. this game have to start when we click Start button and stop by pressing stop button


Plz somebody help me i don't know how to make the image to go around the
box appear and disappear.....
Jan 10 '08 #1
Share this Question
Share on Google+
6 Replies


Ali Rizwan
100+
P: 927
Is there any one who can help me to make a game .This game have to create with visual basic 2005 and it is like there are three images and one by one is appeared and disappeared. Our objective is to try to click fast these images as much as we can. Moreover if we click one image we will get score. this game have to start when we click Start button and stop by pressing stop button


Plz somebody help me i don't know how to make the image to go around the group
box appear and disappear.....
This is the code for generating random nos.

Expand|Select|Wrap|Line Numbers
  1. Randomize
  2.     Label1.caption= Int((6 - 1 + 1) * Rnd + 1)
  3.  
This code will generate random nos between 1-6 if you replace 6 with 3 numbers are generated between 1-3.
Now assign a number to every pic like pic is to 1, pic2 is to 2 and so on.
Now write this code in label1 Change event.

Expand|Select|Wrap|Line Numbers
  1. Select case label1.caption
  2.  
  3. case 1
  4. pic.picture=loadimage(Path of image)
  5.  
  6. case 2
  7. pic.picture=loadimage(Path of image)
  8.  
  9. case 3
  10. pic.picture=loadimage(Path of image)
  11.  
  12. end select
Now pics you need to show are randomly appeared.

Regards
>> ALI <<
Jan 10 '08 #2

P: 4
can u show me ur form bcoz i don't get it well??
should i declare label1_caption as random or integer?
what should i put inside "pic.picture" ?
Jan 10 '08 #3

Ali Rizwan
100+
P: 927
I ll make a demo for you.
OK
For further helps you can contact me by mails or by Yahoo! messenger.
You ll find my address from my profile (by clicking on my name or avatar).

REGARDS
>> ALI <<
Jan 10 '08 #4

P: 4
okay and thanks a lot
Jan 10 '08 #5

P: 9
You can use the following:

I use it to rotate 6 different pictures in a program I am writeing.

Place a timer called "RotatePic" set to time to rotate pictures.
Load one of the pictures in a picture box called "picRotate"
Load the other pictures in image boxs indexed 0 thru 7

Public Sub RotatePic_Timer()

Static thispic As Integer

If thispic = 7 Then thispic = -1
thispic = thispic + 1

If (picRotate.Left) > ScaleWidth Then picRotate.Left = -100
picRotate.Picture = imgChrist(thispic).Picture

End Sub
Jan 29 '08 #6

Ali Rizwan
100+
P: 927
can u show me ur form bcoz i don't get it well??
should i declare label1_caption as random or integer?
what should i put inside "pic.picture" ?
label1 is the label control and in pic is the picture control names.
load some pic in picture box.

Regards
>> ALI <<
Jan 30 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.