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 :)

Recommended Answers

All 4 Replies

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.

i'm kind of new to vb so how do you do that exactly?

Hi, Rnd () function generates random number.

Dim iNumber As Integer

   iNumber = Int(2 * Rnd)
   If iNumber = 1 Then
   End If

This code generates 0 or 1 randomly

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.

Be a part of the DaniWeb community

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