Solved

How to link image to http://

Posted on 2007-12-03
6
289 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:jcoehoorn
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:jcoehoorn
ID: 20397610
Oops.  Change it to:
PictureBox1.Image = Image.FromStream(ms)
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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:
jcoehoorn earned 50 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 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