Results 1 to 9 of 9

Thread: Open a Jpeg

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    230

    Open a Jpeg

    Could somebody show me how to open a Jpeg in a PictureBox by using a control button which takes you to an "Open" dialog which allows you to select the picture?

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Open a Jpeg

    What did you find when you researched this? And what didn't work like you expected it to?
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,421

    Re: Open a Jpeg

    try this:

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    4.         Dim ofd As New OpenFileDialog
    5.         ofd.Filter = "Image Files|*.jpg;*.gif;*.bmp;*.png;*.jpeg|All Files|*.*"
    6.         If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
    7.             picturebox1.image = New Bitmap(ofd.FileName)
    8.         End If
    9.     End Sub
    10.  
    11. End Class

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    230

    Re: Open a Jpeg

    Thank You

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,421

    Thumbs down Re: Open a Jpeg

    Quote Originally Posted by weirddemon View Post
    What did you find when you researched this? And what didn't work like you expected it to?
    This website, like others, is meant to help people. If you don't share your solution, how can others benefit from that knowledge?

  6. #6
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Open a Jpeg

    Quote Originally Posted by .paul. View Post
    This website, like others, is meant to help people. If you don't share your solution, how can others benefit from that knowledge?
    You're quoting me out of context. I didn't have the solution. I could have come up with a copy and paste solution, but why should I, when it's clear the OP hasn't attempted anything on his own yet? I wanted to help him reach it on his own and help fix the mistakes he made by actually learning and not copy and pasting.

    There's a good chance he has no idea how that code works. He only knows that it does and that's all.

    99% of the other members, including the mods, I think, would agree with me. I didn't withhold the information to hinder learning, which is what that quote was getting at. I didn't provide it, so that learning would progress, but it was in the best possible way.

    But, since you did decide to quote me, it's important that others understand the context of that quote. This post is where it originated and it's clearly a very different situation.
    Last edited by weirddemon; Sep 20th, 2010 at 10:20 PM.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

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

    Re: Open a Jpeg

    Quote Originally Posted by .paul. View Post
    This website, like others, is meant to help people. If you don't share your solution, how can others benefit from that knowledge?
    Doing the thinking for people teaches them that they don't have to think for themselves. It might solve the immediate problem but it doesn't make them a better developer. Trying and failing is an important part of the learning process. Not trying and having someone else do it for you is not learning at all. Helping someone fix the code they've already tried is far more beneficial. It might take more time and more effort, but the reward is far greater. You may think you are, but you're not really doing people any great favour by providing cut and paste solutions with no explanation and no effort on their part, assuming that their goal is to become a better developer.
    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

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 2010
    Posts
    230

    Re: Open a Jpeg

    guys i did not mean to start a debate here. The bottom line is someone did post the code. It does work and after looking at the code i do understand what the different parts of it do. I realize that many posters would not take any time to understand the solution they are given and simply cut and paste it so i can understand your frustrations. I have posted a few other questions since asking this one and have included code snippets that i am working with.

    Again i do thank you all for your help here.

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

    Re: Open a Jpeg

    That's fine, but I just Googled and found pretty much the same thing already one the web.

    http://www.google.com.au/search?q=op...ient=firefox-a

    That's pretty much what weirddemon was getting at : look first, ask questions later.
    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

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