我正在研究项目(vb.net),该项目从网站读取文本并将其保存到.sdf数据库,然后将其打印出来
到目前为止,我可以阅读从我的项目打开的第一个Internet Explorer页面中的元素,当我单击它时,第一页具有选择语言的链接,它打开了另一个窗口(不是选项卡),这是我的问题所在无法从第二个Internet Explorer窗口中读取任何元素值
我如何才能致电我的应用程序,哪个Internet Explorer窗口需要从中获取元素值?
这是我的代码
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ie = New SHDocVw.InternetExplorer
With ie
.Visible = True
.Navigate("http://11.2.114.155/")
Do Until Not .Busy And .ReadyState = 4
Loop
doc = ie.Document
End With
ie = Nothing
End Sub
此Sub用于从网页推断数据:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
elements = doc.getElementsByName("AccountNo")
elements1 = doc.getElementsByName("AcctTitle")
elements2 = doc.getElementsByName("NamBenef")
elements3 = doc.getElementsByName("TCY_Amount")
elements4 = doc.getElementsByName("InstrDate")
nachnameValueInput = elements(0)
nachnameValueInput1 = elements1(0)
nachnameValueInput2 = elements2(0)
nachnameValueInput3 = elements3(0)
nachnameValueInput4 = elements4(0)
On Error Resume Next
Dim DM1 As DataTable = ds.Tables("CheqDetail")
Dim DM2 As DataView = DM1.DefaultView
Dim DM As DataRowView = DM2.AddNew()
Dim SQ As Integer = 1
If dv.Count > 0 Then SQ = dv.Item(0).Item("SQ") + 1
DM("SQ") = SQ
If IsDBNull(nachnameValueInput.getAttribute("Value").ToString) = False Then DM("AccNUM") = nachnameValueInput.getAttribute("Value").ToString
If IsDBNull(nachnameValueInput1.getAttribute("Value").ToString) = False Then DM("AccNAM") = nachnameValueInput1.getAttribute("Value").ToString
If IsDBNull(nachnameValueInput2.getAttribute("Value").ToString) = False Then DM("BinfNAM") = nachnameValueInput2.getAttribute("Value").ToString
If IsDBNull(nachnameValueInput3.getAttribute("Value").ToString) = False Then DM("AmountNUM") = Val(nachnameValueInput3.getAttribute("Value").ToString)
If IsDBNull(nachnameValueInput3.getAttribute("Value").ToString) = False Then DM("AmountCHR") = ConvertNumbersToWords(Convert.ToDecimal(Val(nachnameValueInput3.getAttribute("Value")).ToString), "دينار", "درهم", "فقط(", ")لاغير.")
If IsDBNull(nachnameValueInput.getAttribute("Value").ToString) = False Then
If IsDate(nachnameValueInput4.getAttribute("Value").ToString) = True Then
DM("IssueDate") = nachnameValueInput4.getAttribute("Value").ToString
Me.DateTimePicker1.Value = nachnameValueInput4.getAttribute("Value").ToString
End If
End If
DM("ApproveNUM") = TextBox9.Text + TextBox8.Text + TextBox7.Text
DM.EndEdit()
cn.Open()
ad.Update(ds, "CheqDetail")
cn.Close()
ds.AcceptChanges()
MsgBox("تم جلب البيانات بنجاح")
Me.BindingSource1.Position = Me.BindingSource1.Count - 1
End With
End Sub