Results 1 to 8 of 8

Thread: Looping and Input...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    Looping and Input...

    Hello,

    I have a little situation and i am not sure of the best way to do it.

    - My program lets the user select a folder
    - From that folder i need to select all .png files
    - One by one i need to load them into a picture box, await a button press and then go to the next image.

    The above that i have typed in red is where im not sure what to do. The other steps i can do.

    Any pointers or help would be great,
    thanks.
    If a post has been usefull then Rate it!

  2. #2
    Fanatic Member
    Join Date
    Aug 2010
    Posts
    624

    Re: Looping and Input...

    What about creating a string array with all the file locations stored within it, then increase the index being shown in the picturebox by 1 each time the button is clicked?

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Looping and Input...

    I like that solution, but would offer one alternative based on ignorance: Load all the files into a queue of images rather than a string array of files. The string array would almost certainly be easier, but if there was any signficiant time required to load an image, then loading all the images would have a bit of an advantage in that it could be performed as a background process, so that images are being found and added to the queue even as the UI is waiting for the user to press that button.

    In any case, a Queue object might be superior to an array. There wouldn't be an index, you would just be stripping the next item off the queue to load into the picturebox.
    My usual boring signature: Nothing

  4. #4
    Fanatic Member
    Join Date
    Aug 2010
    Posts
    624

    Re: Looping and Input...

    Quote Originally Posted by Shaggy Hiker View Post
    I like that solution, but would offer one alternative based on ignorance: Load all the files into a queue of images rather than a string array of files. The string array would almost certainly be easier, but if there was any signficiant time required to load an image, then loading all the images would have a bit of an advantage in that it could be performed as a background process, so that images are being found and added to the queue even as the UI is waiting for the user to press that button.

    In any case, a Queue object might be superior to an array. There wouldn't be an index, you would just be stripping the next item off the queue to load into the picturebox.
    Yes from your explanation that does sound better than my method, if people are loading 1900x1600 images with max quality it might take a while for the picture box to load, I'd never heard of a queue before so I might have to do some reading!

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Looping and Input...

    You HAVE heard of a List (of T), which is probably the most common of the generic objects, but there are also the Queue(of T), Stack(of T), and Cup (of T), though that last one isn't found in the Generic namespace, but rather in the British namespace. There is also the Dictionary, and a few others that I have forgotten about. They all have their uses, but the List is the most commonly used.
    My usual boring signature: Nothing

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Looping and Input...

    Quote Originally Posted by Shaggy Hiker View Post
    You HAVE heard of a List (of T), which is probably the most common of the generic objects, but there are also the Queue(of T), Stack(of T), and Cup (of T), though that last one isn't found in the Generic namespace, but rather in the British namespace. There is also the Dictionary, and a few others that I have forgotten about. They all have their uses, but the List is the most commonly used.
    I just boosted your reputation for the original solution but now I want to take it back for that Cup(Of T) line.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Fanatic Member
    Join Date
    Aug 2010
    Posts
    624

    Re: Looping and Input...

    Quote Originally Posted by Shaggy Hiker View Post
    You HAVE heard of a List (of T), which is probably the most common of the generic objects, but there are also the Queue(of T), Stack(of T), and Cup (of T), though that last one isn't found in the Generic namespace, but rather in the British namespace. There is also the Dictionary, and a few others that I have forgotten about. They all have their uses, but the List is the most commonly used.
    Yeah I've used List(Of T) before and I've had Cup(Of T) before, but I've never had the occassion to use Queue(Of T), so thank you!

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Looping and Input...

    I regret to say that I spent a few hours last night contemplating how to turn that particular pun into a functional class. Eventually it occured to me that I might change it to Spot (of T), since we do lots of GIS work. Perhaps I could use that class to handle lat/long information in different formats. However, forcing such a solution into a generic design just for the sake of a pun just doesn't seem worthwhile.
    My usual boring signature: Nothing

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