English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I dont have much of a clue about this
Using visual basic express how do I get it to randomly select a Jpeg from a folder when I press a button . Is there a simle code that will perofrm this task

2007-03-13 07:59:57 · 4 answers · asked by Glendon 1 in Computers & Internet Programming & Design

4 answers

Here is some psedo code to guide you.

1.) You need to list all jpg file types in a given directory. Each file path in this listing will be loaded into a string array or collection.

2.) Once the array/collection is loaded with the listings. Determine the number of items loaded using either the collections count property or the Ubound(array) function. You can also use an incremented counter variable and add one each time a file was added to teh array/collection

3.) Now that you know the number of files in teh collection generate a random number beetween 0 and the COUNT

4.) using this random number. use it as an index to read the path stored in an array/collection

5.)with the path determined in step 4 open the file and place it in a picture box control.

2007-03-13 09:25:57 · answer #1 · answered by MarkG 7 · 0 0

You need to use the RAND() Function to randomly select the file.

2007-03-13 08:09:02 · answer #2 · answered by Sane 6 · 0 0

try this
<% dim array(9)

randomize

array(1)="rdm1.gif"
array(2)="rdm2.gif"
array(3)="rdm3.gif"
array(4)="rdm4.gif"
array(5)="rdm5.gif"
array(6)="rdm6.gif"
array(7)="rdm7.gif"
array(8)="rdm8.gif"
array(9)="rdm9.gif"
array(0)="rdm0.gif"

upperbound=ubound(array)
lowerbound=0
lrandom = Int((upperbound - lowerbound + 1) * rnd + lowerbound)
response.redirect "images/" & (Array(lrandom))
%>

2007-03-13 10:45:55 · answer #3 · answered by v-1 2 · 0 0

Try here for info
http://www.techtutorials.net/

http://www.theeldergeek.com/

2007-03-13 09:06:46 · answer #4 · answered by george r. n. 5 · 0 0

fedest.com, questions and answers