Results 1 to 5 of 5

Thread: Picture Arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    South of England
    Posts
    6
    Could someone please tell me how to add a picture array? I can call the fuction, declare my variables(I think) but the picture doesn't show.

    Help me!!

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Dim myArr(4) '5 pictures
    MyArr(0) = "C:\mypic1.jpg"
    MyArr(1) = "C"\mypic2.gif"
    etc.

    Set Picture1.Picture = LoadPicture MyArr(0) ' load mypic1
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    You can set an array of paths to pictures, or you can create a control array to a picturebox or an image.

    For instance, add a picturebox to your form.
    Select then copy the picturebox.
    Click on your form again and paste the picturbox back on it.
    The VBIDE will ask if you want to create a control array since there is a control named Picture1 already on the form.
    Say yes. And there you have it, a control array.

    You could also set the Index property of the Picturebox but I found copy & paste to be the quickest way to do it


    -Excalibur

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'or you can load a file's contents into an array
    
    Option Explicit
    
    Dim myArray()
    
    Private Sub Form_Load()
    'access all files within a folder
    
    Dim stFile As String
        Dim stDir As String
        Dim i As Integer
        
        stDir = "C:\myfolder\"
        stFile = Dir$(stDir & "*.*")
        
        Do While stFile <> ""
        stFile = stDir & stFile
        
        ReDim Preserve myArray(i)
          myArray(i) = stFile
          stFile = Dir
           List1.AddItem myArray(i)
          i = i + 1
         
        Loop
    
    End Sub
    Private Sub Command1_Click()
        Dim x As Integer
        'tells you how many pictures were in the file
        x UBound(myArray)
        'to load the picture
        'Set Picture1.Picture = LoadPicture(myArray(any # from zero to x))
        Set Picture1.Picture = LoadPicture(myArray(7))
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Location
    South of England
    Posts
    6

    Thanks

    Thanks for the help!
    Greg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width