我正在尝试开发可以从学术网站搜索批量结果的应用程序或工具。我对所有可以从单行文本框中选择卷号的应用程序进行了编码,并显示了结果。
但是我希望webbrowser控件从多行texbox中选择卷号,逐行,程序应按行数循环,并在完成后将文件保存为pdf。
这是我的代码:
Imports System.Net
Imports System.IO
Imports System.Text
Imports System.Linq
Imports iTextSharp.text.pdf
Imports iTextSharp.text
Imports System.Drawing.Printing
Imports System.Drawing
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
batchresults.Show()
Me.Hide()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("rno").SetAttribute("value", TextBox1.Text)
If CheckBox1.Checked = True Then
WebBrowser1.Document.GetElementById("rno").SetAttribute("value", batchresults.TextBox1.Text.ToArray)
End If
WebBrowser1.Document.GetElementById("commit").InvokeMember("click")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Icon = New Icon("result.ico")
Try
Using client = New WebClient()
Using stream = client.OpenRead("http://www.google.com")
Timer1.Enabled = True
WebBrowser1.Navigate("http://bisesahiwal.edu.pk/allresult/")
Button2.Enabled = False
End Using
End Using
Catch
MsgBox("Connection is not established", MsgBoxStyle.Critical)
Me.Close()
End Try
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
TextBox1.Enabled = False
Button2.Enabled = True
Else
TextBox1.Enabled = True
Button2.Enabled = False
End If
End Sub
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
Button2.Enabled = False
TextBox1.Enabled = True
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
WebBrowser1.Document.GetElementById("rno").SetAttribute("value", TextBox1.Text)
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "9th" Then
WebBrowser1.Document.GetElementById("class").SetAttribute("value", "1")
ElseIf ComboBox1.Text = "10th" Then
WebBrowser1.Document.GetElementById("class").SetAttribute("value", "2")
ElseIf ComboBox1.Text = "11th" Then
WebBrowser1.Document.GetElementById("class").SetAttribute("value", "3")
ElseIf ComboBox1.Text = "12th" Then
WebBrowser1.Document.GetElementById("class").SetAttribute("value", "4")
End If
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
If ComboBox2.Text = "2018" Then
WebBrowser1.Document.GetElementById("year").SetAttribute("value", "2018")
ElseIf ComboBox2.Text = "2017" Then
WebBrowser1.Document.GetElementById("year").SetAttribute("value", "2017")
ElseIf ComboBox2.Text = "2016" Then
WebBrowser1.Document.GetElementById("year").SetAttribute("value", "2016")
ElseIf ComboBox2.Text = "2015" Then
WebBrowser1.Document.GetElementById("year").SetAttribute("value", "2015")
ElseIf ComboBox2.Text = "2014" Then
WebBrowser1.Document.GetElementById("year").SetAttribute("value", "2014")
ElseIf ComboBox2.Text = "2013" Then
WebBrowser1.Document.GetElementById("year").SetAttribute("value", "2013")
ElseIf ComboBox2.Text = "2012" Then
WebBrowser1.Document.GetElementById("year").SetAttribute("value", "2012")
End If
End Sub
Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
If ComboBox3.Text = "Annual" Then
WebBrowser1.Document.GetElementById("sess").SetAttribute("value", "1")
ElseIf ComboBox3.Text = "Supplementary" Then
WebBrowser1.Document.GetElementById("sess").SetAttribute("value", "2")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
WebBrowser1.Navigate("http://bisesahiwal.edu.pk/allresult/")
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label5.Text = batchresults.TextBox1.Lines.Count()
End Sub
End Class