Demo entry 6742895

寻找png

   

Submitted by anonymous on May 19, 2018 at 17:06
Language: VB.net. Code size: 2.3 kB.

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub 刷新ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 刷新ToolStripMenuItem.Click
        WebBrowser1.Refresh()
    End Sub

    Private Sub 菜单ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 菜单ToolStripMenuItem.Click
        WebBrowser1.GoBack()
    End Sub

    Private Sub 向前ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 向前ToolStripMenuItem.Click
        WebBrowser1.GoForward()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim url As String
        url = TextBox1.Text
        WebBrowser1.Navigate(url)
    End Sub

    Private Sub 显示htmlToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 显示htmlToolStripMenuItem.Click
        TextBox2.Text = ""
        TextBox2.Text = WebBrowser1.DocumentText
    End Sub

    Private Sub 寻找图片ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 寻找图片ToolStripMenuItem.Click
        Dim html As String = WebBrowser1.DocumentText
        Dim PNGTEXT As String = ""
        Dim count As Integer = 0
        For i = 0 To html.Length - 1
            If html(i) = "." Then
                If html(i + 1) = "p" Then
                    If html(i + 2) = "n" Then
                        If html(i + 3) = "g" Then                                            '寻找“.png”字符
                            For b = 1 To 50                                                  '限制往前找最大50个字符长度的图片名
                                If html(i - b) = "/" Then
                                    count = count + 1
                                    PNGTEXT = PNGTEXT + "第" + count.ToString + "张" + " " + html.Substring(i - b + 1, b + 4) + vbCrLf  '4表示加上“.png”+
                                    Exit For
                                End If
                            Next
                        End If
                    End If
                End If
            End If
        Next
        TextBox3.Text = PNGTEXT
    End Sub

    Private Sub 清空ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 清空ToolStripMenuItem.Click
        TextBox3.Text = ""
    End Sub
End Class

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).