Results 1 to 10 of 10

Thread: Picture Help ! (resovled)

  1. #1

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152

    Picture Help ! (resovled)

    I was wondering if anyone new how to grab an image from a URL. Lets say http://us.i1.yimg.com/us.yimg.com/i/ww/m6v9.gif that is just the yahoo.com top image. I want to take that image from the web and download it. The a user presses a button and the picturebox becomes that picture.


    Or....
    Say there is a form with a picture control, a text box, and a buttonm. The user types a url of a picture such as (http://us.i1.yimg.com/us.yimg.com/i/ww/m6v9.gif) in the textbox and the presses the button. The picture gets loaded in the picture box.
    Thanks for any help
    Sean
    Last edited by Stick; Jan 29th, 2003 at 01:16 AM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This from VBCodeBook ....
    VB Code:
    1. Imports System
    2. Imports System.IO
    3. Imports System.Net
    4. Imports System.Text
    5. 'This import is required to gain access to the new namespace
    6. Imports LoadImageFromWeb.ImageStream
    7.  
    8. Public Class Form1
    9.     Inherits System.Windows.Forms.Form
    10.     Private Sub btnLoadWebImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadWebImage.Click
    11.         'Loads a picture box with an image from a website
    12.         Const PATH_TO_IMAGE = "http://www.vbforums.com/images/ads/current.gif"
    13.         Dim xImage As ImageToDownload = New ImageToDownload(PATH_TO_IMAGE)
    14.         Dim xStream As MemoryStream = xImage.BeginDownload()
    15.         picFromWeb.Image = Image.FromStream(xStream)
    16.     End Sub
    17.  
    18. End Class
    19.  
    20. Namespace ImageStream
    21.  
    22.     Public Class ImageToDownload
    23.         Dim sI2D_URL2Download As String
    24.         Const PREFIX = "http://"
    25.  
    26.         Public Sub New(ByVal sURL As String)
    27.             Me.sI2D_URL2Download = sURL
    28.         End Sub
    29.  
    30.         Public Function BeginDownload() As MemoryStream
    31.             Dim msImage As MemoryStream
    32.             Dim wcClient As WebClient = New WebClient()
    33.  
    34.             If Not sI2D_URL2Download.ToLower().StartsWith("http://") Then sI2D_URL2Download = PREFIX + sI2D_URL2Download
    35.             msImage = New MemoryStream(wcClient.DownloadData(sI2D_URL2Download))
    36.  
    37.             Return msImage
    38.         End Function
    39.     End Class
    40.  
    41. End Namespace

  3. #3

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152

    ahhh thanks but i need more help

    I can't figure out how to make this work..
    can anyone help

    thanks

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    umm, wait then ..........

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    try this now .....
    Attached Files Attached Files

  6. #6

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152
    thanks..
    I am stupid at vb..

    I used to kinda know it now it is all BLAH!
    thanks alot

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    working ??

  8. #8

    Thread Starter
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152
    Yes....
    Thanks man.

  9. #9
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    in vb doing

    dim MyClass as Class = new Class() isnt the same as
    dim myClass as new Class()
    ?
    \m/\m/

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by PT Exorcist
    in vb doing

    dim MyClass as Class = new Class() isnt the same as
    dim myClass as new Class()
    ?
    in this case , it seems same thing .

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