User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 403,515 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,922 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 373 | Replies: 4 | Solved
Reply
Join Date: Feb 2008
Posts: 9
Reputation: sddproject is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sddproject sddproject is offline Offline
Newbie Poster

Random Picture Generator

  #1  
Jul 17th, 2008
Hi everyone!

I want to have a coin toss on my program: i have two images (a heads and tails) and i want the user to click on a button which will generate one of these pictures randomly.

There's all this code on how to create a random number generators, but not pictures!

Please help!
thank you
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,213
Reputation: debasisdas is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 78
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Nearly a Posting Virtuoso

Re: Random Picture Generator

  #2  
Jul 17th, 2008
1.assign two flags for the files.
2.generate a random number.
3.display one picture if the number is even or the other if that is odd.
Share your Knowledge.
Reply With Quote  
Join Date: Feb 2008
Posts: 9
Reputation: sddproject is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sddproject sddproject is offline Offline
Newbie Poster

Re: Random Picture Generator

  #3  
Jul 17th, 2008
i'm kind of new to vb so how do you do that exactly?
Reply With Quote  
Join Date: Feb 2008
Location: Sivakasi, Tamilnadu, India
Posts: 403
Reputation: selvaganapathy is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 69
selvaganapathy's Avatar
selvaganapathy selvaganapathy is online now Online
Posting Pro in Training

Re: Random Picture Generator

  #4  
Jul 17th, 2008
Hi, Rnd () function generates random number.
  1. Dim iNumber As Integer
  2.  
  3. Randomize
  4. iNumber = Int(2 * Rnd)
  5. If iNumber = 1 Then
  6. 'Head
  7. Else
  8. 'Tail
  9. End If

This code generates 0 or 1 randomly
KSG
Reply With Quote  
Join Date: Jul 2008
Posts: 31
Reputation: Teropod is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
Teropod Teropod is offline Offline
Light Poster

Re: Random Picture Generator

  #5  
Jul 17th, 2008
rnd is tricky one every time you start application it will to same order for example make it in command button first time you click it will flip 1 second 1 third 1 fourth 0 fifth 0.

You need to replace that number 2 with some number that can't be so much predicted such as date + time numbers and look will resolut be odd or even.

Or you can just make timer with interval 1 make integer when timer activate incerease that integer by one and if that integer is bigger then 1 make it 0 that really hard to predict.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 1:00 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC