Help with Simple task.. (I think) 
Author Message
 Help with Simple task.. (I think)

Ok I have a project I am working on, on the Parant form I use a Image as the
background. What I would like to do it have the program upon launch randomly
pic from various other images in a certain directory and use it for the
background image? Is this possible? If so how might one go about doing
this..

Thanks

Dennis
DataOne Communications/Director MIS



Fri, 16 Nov 2001 03:00:00 GMT  
 Help with Simple task.. (I think)

Quote:

>Ok I have a project I am working on, on the Parant form I use a Image as the
>background. What I would like to do it have the program upon launch randomly
>pic from various other images in a certain directory and use it for the
>background image? Is this possible? If so how might one go about doing
>this..

The following code searches for all BMP files in a directory, fills a dynamic
array with the names of all the files, then generates a random number to
select one of the files and loads it as the background of the form:

Private Sub Form_Load()
    Dim sFile As String
    Dim sFileList() As String
    Dim iCount As Integer, iSelect As Integer
    sFile = Dir("c:\mydir\*.bmp")
    While Len(sFile)
        iCount = iCount + 1
        ReDim Preserve sFileList(1 To iCount)
        sFileList(iCount) = sFile
        sFile = Dir
    Wend
    Randomize
    iSelect = Int(Rnd * iCount) + 1
    Me.Picture = LoadPicture("d:\graphic files\" & sFileList(iSelect))
End Sub

Lee Weiner
weiner AT fuse DOT net
http://home.fuse.net/lweiner



Fri, 16 Nov 2001 03:00:00 GMT  
 Help with Simple task.. (I think)

Quote:


>Lee Weiner
>weiner AT fuse DOT net
>http://home.fuse.net/lweiner

Lee, Thank you for the code, It is very apprecated. The use of the array is
very helpfull as I am very rusty when it come to using them..

Thanks again.

Dennis



Fri, 16 Nov 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Need help with a simple task

2. Help a beginner with a simple task!

3. Simple Task...a text file...please help

4. Simple problem - I thought!

5. Simple Query, I thought

6. So simple and yet so damn strange( I think)

7. Simple basic query (I think)

8. Simple Data Control question (I think)

9. a simple SQL question, i think.

10. A simple FindFirst command ... I thought

11. really simple DB question, i think

12. Simple VB6 question - I think!!

 

 
Powered by phpBB® Forum Software