

If you had a line of people you wanted to do something on demand you could line them up and give each a number.
#Show me random pictures code
Very few lines of code and seems straight forward logic to me. Use the value to set the picturebox image to the image stored at that index value. Remove the value at that index from the List(Of Integer) so you can't choose it again. Use an instance of the Random object to choose an index into the List(Of Integer) and get the value stored there. Populate another List(Of Integer) with the numbers 0 to the image list count - 1. Just add the images to a List(Of Image) or List(Of Bitmap). So, I would say that there really isn't a simplest way to do this, because the simplest way would probably suck at times.I find the concept or implementation of "drawing objects from a hat" pretty simple, but perhaps that is just me.

In other words, if the first picture is 3, then don't show 3 again until you have seen all the others in the set. You may want to see all N pictures in random order, but no repeats until after you have gone through all N. There's a lot of ways to go about it, but one of the best is to load your images into an array, randomly select an array index, then set the picturebox's Image property to that image: But it's better to have one PictureBox that you set the image to randomly. You could sort of implement a form where you load an array of PictureBox controls, then randomly pick one of them and add them to the form. A "picture box" is a control that you use to display an image. I think your main problem, based on the text alone, is you need to realize a "picture box" and an "image" are two different things. This tends to not get very good responses, and in the worst case attracts people who get excited about finding elaborate ways to make you feel bad about answering the question. You asked a question about a simple problem without displaying much effort on your own. Did you expect a forum cookie? Instead you look like a troll, and you're certainly not making look good to a new user. Wait for someone with no self respect and in need of a perceived validation of their worth to do it for you in hopes of earning a forum cookie?Bad form. So, I would say that there really isn't a simplest way to do this, because the simplest way would probably suck at times. Or, you may want something that I can't quite put into a single sentence, so I'll use a few: Suppose you have a set of N pictures. Instead, you may want the sequence to be N, followed by anything that is not N. However, with a picturebox, you may or may not want a true random sequence.

There are times when you really want to get a random sequence, so if 2,2,2,2 comes up, then so be it. The problem with a true random sequence is that you could get 2, 2, 2, 2. After all, I wouldn't care to tackle this particular problem without knowing at least one key point: Do you REALLY want random, or do you want.almost random? It's also the first time I've explored an API or read up on documentation for a purpose other than proofing/editing/writing.Wait for someone with no self respect and in need of a perceived validation of their worth to do it for you in hopes of earning a forum cookie?Technically, that's correct, but probably not all that helpful. I made this just as a way to practice JavaScript and generate random images that would make me happy to look at. Once I got the API working and displaying, the image dimensions were wild - turns out I was including the image dimensions in the source URL, so I pulled that out and created a CSS class for img since there was only going to be one displaying. I tried using class names and setting IDs, and I couldn't seem to target it, so I flipped to this different strategy using a tutorial as a guide. For ( let i = 0 i < numItemsToGenerate i ++ )Īt first, it was wild to think about using JS only and not building in any HTML to display the image, so first I tried building a div into the HTML body.
