Webbrowser Dispose

If rows Mod 5 = 0 Then
WebBrowser1 = Nothing
WebBrowser1 = New WebBrowser
WebBrowser1.ScriptErrorsSuppressed = True
WebBrowser1.Location = New Point(2, 45)
WebBrowser1.Size = New Size(942, 349)
End If

HTML Element GET VB.net

Dim scripts1 As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName(“a”)
For Each scripts1_ As HtmlElement In scripts1
If scripts1_.GetAttribute(“classname”) = “ulink” Then
range1 = sheet1.Cells(rows, 1)
range1.Value = scripts1_.GetAttribute(“href”)
rows += 1
End If

Delay Module (CPU Reduced)

Private Sub Delay1(ByVal DelayInSeconds As Integer)
Dim ts As TimeSpan
Dim targetTime As DateTime = DateTime.Now.AddSeconds(DelayInSeconds)
ts = targetTime.Subtract(DateTime.Now)
Application.DoEvents() ‘ keep app responsive
System.Threading.Thread.Slee p(50) ‘ reduce CPU usage
Loop While ts.TotalSeconds > 0
End Sub

Excel Operation Initialization in VB.NET

Imports Excel = Microsoft.Office.Interop.Excel

Dim app As New Excel.Application
Dim book As Excel.Workbook = app.Workbooks.Open(“C:\m\m.xlsx”)
Dim sheet1 As Excel.Worksheet = book.Sheets(1)
‘Dim sheet2 As Excel.Worksheet = book.Sheets(2)
‘Dim sheet3 As Excel.Worksheet = book.Sheets(3)
Dim range1 As Excel.Range
Dim range2 As Excel.Range
Dim range3 As Excel.Range
Dim range4 As Excel.Range
Dim range5 As Excel.Range
Dim range6 As Excel.Range
Dim pages As Integer = 1
Dim rows As Integer = 1


VB.NET Import to Data Table

Imports System.Data
Imports Excel = Microsoft.Office.Interop.Excel

Dim connectionString As String ‘ Used to store the connection string
Dim customerList As New DataSet ‘ Used to store the temp records readed from the Excel file
Dim excelData As OleDb.OleDbDataAdapter

Dim fileName As String = “c:\test.xlsx”

connectionString = String.Format(“Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=””Excel 12.0;HDR=YES””;”, fileName)
excelData = New OleDb.OleDbDataAdapter(“SELECT * FROM [Sheet1$]”, connectionString)
excelData.TableMappings.Add(“Sheet1”, “S1”)
DataGridView1.DataSource = customerList.Tables(0)
‘Datatable Initialization

Dim dt As Data.DataTable
Dim dr As DataRow
dt = customerList.Tables(0)
For Each dr In dt.Rows
If (InStr(dr(1).ToString, “自我救赎”)) Then
End If

‘For i As Integer = 0 To DataGridView1.Rows.Count
‘ DataGridView1.CurrentCell = DataGridView1(1, i)
‘ If InStr(DataGridView1.CurrentCell.Value.ToString, “纵横四海”) Then
‘ MsgBox(DataGridView1.CurrentCell.Value)
‘ MsgBox(DataGridView1.CurrentCell.RowIndex)
‘ End If

‘ ‘MsgBox(DataGridView1.CurrentCell.Value)