Glad to see you active so ima take advantage on that : P
It's only showing me 1 image when i press the button : /Code:Dim rndVal As New Random Dim i As Integer Dim BGimage(6) BGimage(0) = Resources.image_1 BGimage(1) = Resources.image_2 BGimage(2) = Resources.image_3 BGimage(3) = Resources.image_4 BGimage(4) = Resources.image_5 BGimage(5) = Resources.image_6 BGimage(6) = Resources.image_7 For i = 0 To 6 Me.BackgroundImage = BGimage(i) Next
it isn't randomizing.
Thanks !
PS: I know that you are going to move it, but it's the only active section on LG : /
Results 1 to 7 of 7
Thread: Arti
- 03 Jun. 2012 01:38pm #1
Arti
- 03 Jun. 2012 01:46pm #2
Why would it show a random image? You're not once using that Random variable you declared.
You're setting 7 images, looping from 0 to 6 and updating the background image of one object. It's going to update the background image 7 times, but it's going to happen so fast you're only going to see the last one.
- 03 Jun. 2012 01:56pm #3
It's for a small bot i'm making for my dad.
Oh, I thought that every time I pressed the button, it would randomize the form background and give me one from the Array list.
- 03 Jun. 2012 02:04pm #4
It's not going to show a random number if you just iterate through 1 to 7...
I haven't used .NET in years, but try this:
Code:Dim rndVal As New Random(System.DateTime.Now.Millisecond) Dim i As Integer Dim BGimage(6) BGimage(0) = Resources.image_1 BGimage(1) = Resources.image_2 BGimage(2) = Resources.image_3 BGimage(3) = Resources.image_4 BGimage(4) = Resources.image_5 BGimage(5) = Resources.image_6 BGimage(6) = Resources.image_7 Me.BackgroundImage = BGimage(rndVal.Next(0,6))
- 03 Jun. 2012 02:32pm #5
- 03 Jun. 2012 05:00pm #6
You would call the function you created every 20 seconds wherever the call clause might be, from what I surmise. You could do this via Timer by updating the interval, or using threads (probably overkill) or a related avenue (looping would probably work as well).
- 03 Jun. 2012 08:36pm #7