locked
Inserting Images into Array RRS feed

  • Question

  • Hi, I am developing a mobile application using Visual Studio 2005, and I was wondering how to store images into arrays?

     

    I have declared the image array and ensured that the filepaths are correct:

    Dim strPlantFile() As Image = {New Bitmap("file:///C:\Users\Alex\Documents\Visual Studio 2005\RFIDApplication\RFIDApplication\images\cattail_thumb.jpg"), New Bitmap("file:///C:\Users\Alex\Documents\Visual Studio 2005\RFIDApplication\RFIDApplication\images\pipewort_thumb.jpg"), New Bitmap("file://C:\Users\Alex\Documents\Visual Studio 2005\RFIDApplication\RFIDApplication\images\subsuban_thumb.jpg")}

     

    Also, I have created a loop to loop through the array to retrieve the relevant images:

    For count = 0 To strPlantID.Length - 1

    If (txtTagID.Text = strPlantID(count)) Then

    pboxImg.Image = strPlantFile(count)

    Exit For

    End If

    Next

     

    But I get the error that: Value does not fall within the expected range.

     

    Did I make any mistake? How should I rectify it?

    Tuesday, May 15, 2007 11:40 AM

Answers

  • I usually work with the ImageList class,

    take a look at this article:

    http://www.devbuzz.com/content/zinc_evb_imagelist_pg1.asp

    I think the error you're getting above is because your arrays (strPlantFile and strPlantID) doesn't have the same dimensions. Check your strPlantID declaration
    Tuesday, May 15, 2007 1:30 PM

All replies

  • I thougth in  a possible solution but before, how have you declared your array?

    Regards


    Tuesday, May 15, 2007 11:56 AM
  • What is the proper way of declaring an array to contain images?
    Tuesday, May 15, 2007 1:08 PM
  • I usually work with the ImageList class,

    take a look at this article:

    http://www.devbuzz.com/content/zinc_evb_imagelist_pg1.asp

    I think the error you're getting above is because your arrays (strPlantFile and strPlantID) doesn't have the same dimensions. Check your strPlantID declaration
    Tuesday, May 15, 2007 1:30 PM
  • Thank you!.. It worked!..
    Tuesday, May 15, 2007 3:49 PM