views:

30

answers:

2

I am having a problem displaying some pictures (more than one) in a picturebox.

 <div id="salary_total" style="display: block;"><table style="border: 3px solid rgb(71, 5, 6); padding-right: 1px;" bgcolor="#ffffff" cellpadding="0" cellspacing="0"><tbody><tr><td><img src="./images/counter/b.gif"></td>
<td><img src="./images/counter/3.gif" border="0"></td>
<td><img src="./images/counter/3.gif" border="0"></td>
<td><img src="./images/counter/0.gif" border="0"></td>
<td><img src="./images/counter/8.gif" border="0"></td>
</tr></tbody></table> 

those picture links, shows like a number like 3308, and it changes every time the page loads. how can I display those pictures (next to each other) in a picturebox.

Try
    Dim htmlDocument As HtmlDocument = Me.WebBrowser1.Document
    Dim htmlElementCollection As HtmlElementCollection = htmlDocument.Images
    For Each htmlElement As HtmlElement In htmlElementCollection
        Dim imgUrl As String = htmlElement.GetAttribute("src")
        If imgUrl.Contains("counter") Then
            Me.PictureBox1.ImageLocation = imgUrl.Substring(0, 41)
        End If
    Next

This one works for the first picture, how can I have like 3 more pictureboxs, and do the same for the other 3 pictures?, like the 3.gif will go to the 1st picturebox, and so on?!

A: 

First, you ImageLocation will come out like this:

http://www.link.com./images/counter/8.gif

That's probably not what you intended.

Second, Shoban said that you should be using regular text and CSS. He's right.

Third, If you want to display multiple images in a single picturebox, you will need to make a single image object and draw the other images into it. There are VB.Net functions for that and also native Windows API (CopyRect?).

You can use multiple picture boxes if you like.

Eyal
updated the question! thx
Beho86
A: 

I figured it out: Here is the solution! Thanks

Try
            Dim htmlDocument As HtmlDocument = Me.WebBrowser1.Document
            Dim htmlElementCollection As HtmlElementCollection = htmlDocument.Images
            Dim ImagesFound As Integer = 0
            For Each htmlElement As HtmlElement In htmlElementCollection
                Dim imgUrl As String = htmlElement.GetAttribute("src")
                If imgUrl.Contains("counter") Then
                    ImagesFound+=1
                    Select Case ImagesFound
                         Case 1 
                              PictureBox1.ImageLocation = imgUrl
                              Label1.Text = PictureBox1.ImageLocation.ToString()
                         Case 2 
                              PictureBox2.ImageLocation = imgUrl
                              '... etc.
                    End Select

                End If
            Next
        Catch ex As Exception
        End Try
Beho86