Results 1 to 9 of 9

Thread: How to display the internet image in picturebox using HttpWebRequest

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    How to display the internet image in picturebox using HttpWebRequest

    Hi,
    I am beginner, and try it a long time and can not find the solution...

    Just want show the picture which in the internet...I will try using HttpWebRequest, because it will using in the mobile..


    Thx

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    Re: How to display the internet image in picturebox using HttpWebRequest

    you need to use the HttpWebResponse & then it's GetResponseStream
    then you can create an image using Image.FromStream.

    like this ....
    VB Code:
    1. [COLOR=Blue]Dim[/COLOR] request [COLOR=Blue]As[/COLOR] HttpWebRequest = [COLOR=Blue]DirectCast[/COLOR](HttpWebRequest.Create("http://www.google.co.uk/intl/en_uk/images/logo.gif"), HttpWebRequest)
    2.         [COLOR=Blue]Dim[/COLOR] response [COLOR=Blue]As[/COLOR] HttpWebResponse = request.GetResponse
    3.  
    4.         [COLOR=Blue]Dim[/COLOR] img [COLOR=Blue]As[/COLOR] Image = Image.FromStream(response.GetResponseStream)
    5.  
    6.         PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
    7.         PictureBox1.Image = img
    8.  
    9.         response.Close()
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: How to display the internet image in picturebox using HttpWebRequest

    It work..Thanks..
    Last edited by simoms; Apr 10th, 2006 at 01:20 AM.

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: How to display the internet image in picturebox using HttpWebRequest

    more one question:

    How can I save the picture into the directory, using this method!!

  5. #5
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: How to display the internet image in picturebox using HttpWebRequest

    Theres also a codebank submission by kleinma that shows how to do it using the System.Net.Webclient...

    http://www.vbforums.com/showthread.php?t=387841

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: How to display the internet image in picturebox using HttpWebRequest

    Thanks for your reply...

    I need to use httpRequest to do it, because I need use in the pocket pc

  7. #7
    New Member
    Join Date
    Apr 2006
    Posts
    11

    Re: How to display the internet image in picturebox using HttpWebRequest

    I'm using VB 2005 Basic Express.

    I tried to enter this code, but I get the following error:

    "Type 'HttpWebrequest' is not defined"


    Do I need a different version to be able to use "HttpWebRequest"?

    Thanks!

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: How to display the internet image in picturebox using HttpWebRequest

    Quote Originally Posted by Vmax1001
    I'm using VB 2005 Basic Express.

    I tried to enter this code, but I get the following error:

    "Type 'HttpWebrequest' is not defined"


    Do I need a different version to be able to use "HttpWebRequest"?

    Thanks!
    No, you probably just didn't fully qualify it with its namespace

    Dim MyRequest as System.Net.HttpWebRequest

  9. #9
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: How to display the internet image in picturebox using HttpWebRequest

    Quote Originally Posted by simoms
    more one question:

    How can I save the picture into the directory, using this method!!
    You can save a picture to file using the picturebox itself...

    Lets say your picturebox is called Picturebox1...

    VB Code:
    1. picturebox1.Image.Save([i]File Name Here[/i])

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