Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to randomize
Message
De
08/11/2001 12:28:16
 
 
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00578749
Message ID:
00579197
Vues:
55
>>>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
>
>Don't forget to seed the rand.

Randomize without a seed uses a value based on the system's timer. Is there a pitfall to watch for if you don't specify a seed?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform