Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to randomize
Message
From
07/11/2001 17:40:08
 
 
To
07/11/2001 16:25:48
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00578749
Message ID:
00578793
Views:
49
>hi
>my problem is that I want an image to change randomly between 25 picz every time I press a button?
>
>how du I do?

You could store the file names in a string array and use the Rnd function to obtain a random element from it:
In Form_Load:
Dim aFiles(1 To 25) As String
aFiles(1) = "myfile1.txt"
aFiles(2) = "myfile2.txt"
aFiles(3) = "myfile3.txt"
'.. etc.
Randomize
In your command button's click:
sNextFile = aFiles(Int(25 * Rnd) + 1)
HTH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform