Solved

How to link image to http://

Posted on 2007-12-03
6
286 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now