Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to randomize
Message
De
07/11/2001 17:40:08
 
 
À
07/11/2001 16:25:48
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00578749
Message ID:
00578793
Vues:
47
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform