这将为proxyList中的每个项目循环一次帐户列表,如果帐户列表中有5个项目,proxyList中有10个项目,则此代码将循环50次。这段代码没有任何问题,只是它与您想要的不匹配。
根据您的评论,您希望 accountList 和 proxyList 都平等地向前推进,您应该真正定义一个新类:
Public Class ProxyAccount
Public Proxy As String
Public Account As String
End Class
然后你的代码变成:
Public Class Form1
Public ProxyList As New List(Of ProxyAccount)
For Each pa As ProxyAccount In ProxyList
Dim a as String = pa.Account
Dim z() As String = a.Split(":")
Dim p as String = pa.Proxy
' SENDS WEBREQUESTS BY USING ACCOUNTS AND SETS PROXY '
Next
Next
End Class
或者你也可以这样做:
Public Class Form1
Public ProxyList As New List(Of String)
Public AccountList As New List(Of String)
For i as Integer = 0 To ProxyList.Count - 1
If i >= AccountList.Count Then
Exit For
End If
Dim a As String = AccountList(i)
Dim z() As String = a.Split(":")
Dim p as String = ProxyList(i)
' SENDS WEBREQUESTS BY USING ACCOUNTS AND SETS PROXY '
Next
End Class
这两者中的任何一个都可以正常工作,但是您需要重构代码以使其更清晰。