Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to link image to http://

Posted on 2007-12-03
6
Medium Priority
?
307 Views
Last Modified: 2013-11-26
Hi experts,

I want to display image which located in http://myimages.mysite.com onto PictureBox in VB 2005 forms.
I tried it with following codes with ERROR in line "PictureBox1 = Image.FromFile( http://myimages.mysite.com /upload/pubFilePath)"
Would you please advise me?

Thanks,
HD

    Private Sub PhotoDataGridView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles PhotoDataGridView.CellClick
        If e.RowIndex >= 0 Then
            pubFileName = PhotoDataGridView.Rows(e.RowIndex).Cells("PhotoFileName").Value.ToString
            PictureBox1 = Image.FromFile( http://myimages.mysite.com /upload/pubFilePath) ===> ERROR
        End If
    End Sub
0
Comment
Question by:Takeoutdinner
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:Joel Coehoorn
ID: 20397101
Private Sub PhotoDataGridView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles PhotoDataGridView.CellClick
        If e.RowIndex >= 0 Then
            pubFileName = PhotoDataGridView.Rows(e.RowIndex).Cells("PhotoFileName").Value.ToString
            Dim wc As New System.Net.WebClient()
            Dim ms As New IO.MemoryStream(wc.DownloadData("http://myimages.mysite.com /upload/pubFilePath"))
            PictureBox1 = Image.FromStream(ms)
        End If
    End Sub
0
 

Author Comment

by:Takeoutdinner
ID: 20397174
Hi expert,
This PictureBox1 = Image.FromStream(ms) has eroor message:
Value of Type 'System.Drawing.Image' cannot be converted to 'System.Windows.Forms.Picture'

What should I do ?

Thanks,
0
 
LVL 18

Expert Comment

by:Joel Coehoorn
ID: 20397610
Oops.  Change it to:
PictureBox1.Image = Image.FromStream(ms)
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:Takeoutdinner
ID: 20397730
Hi expert,

When I run it, I have this error message "URI formats are not supported" at "           Dim ms As New IO.MemoryStream(wc.DownloadData("http://sunenergy.oncmc.com /upload/pubFilePath"))"

Your kid advice would be appreciated.

Thanks,

0
 
LVL 18

Accepted Solution

by:
Joel Coehoorn earned 200 total points
ID: 20398095
I just copy/pasted the url you were using.  Looking at it now more closely, I see two things:
1)  You have an extra space in your url.
2)  You don't specify a file name.  Did you mean to use pubFileName from above?

Try this:
IO.MemoryStream(wc.DownloadData("http://sunenergy.oncmc.com/upload/pubFilePath/" & pubFileName))
0
 

Author Comment

by:Takeoutdinner
ID: 20398190
Thanks expert!
It's working fine with this:

          Dim ms As New IO.MemoryStream(wc.DownloadData("http://sunenergy.oncmc.com/upload/" & pubFilePath))
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question