-1
任何人都知道为什么当“for”循环达到极限时我无法得到一个新单词?
的意图是,循环旋转每个新词
但是一些非常错误的做法
=========================== =====
如何退出一个循环到另一个循环?
Private Sub getWord()
Static wordCount As Integer
Dim txtLines As String()
txtLines = TextBox1.Text.Split(CChar(vbCrLf))
If (wordCount < txtLines.Count) Then
WebBrowser1.Navigate("http://www.bing.com/search?q=" & txtLines(wordCount) & "&first=1&FORM=PERE")
wordCount = wordCount + 1
End If
End Sub
Dim i As Integer
Dim max As Integer = 40
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If i >= max Then
getWord()
End If
If (WebBrowser1.ReadyState = WebBrowserReadyState.Complete) Then
For i As Integer = 1 To 40 Step 10
WebBrowser1.Navigate("http://www.bing.com/search?q=" & txtLines(wordCount) & "&first=" & i & "&FORM=PERE")
Next
Dim PageElement As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("a")
Dim lk As String
For Each lks As HtmlElement In PageElement
lk = lks.GetAttribute("href")
ListBox1.Items.Add(lk)
Next
End If
End Sub
的问题是:当循环达到40或41,一个新词应该是启动 这是为什么没有发生 ? – user3606056
@ user3606056 - 你现在的代码永远不会达到40或41.它停在31.你的For'循环只产生值1,11,21和31。 – Enigmativity