一直找不到答案,Inet控件数组问题.帮帮忙认真看下
为什么Inet1_StateChanged 事件的索引值(Index)不是从顺序变化呢? 我在立即窗体中输出了(值太长我给出一小半)
50
52
52
52
52
43
52
52
47
46
48
49
51
53
54
55
56
59
60
67
为什么索引有相同的啊?难道它重复执行?还有上面的图片右边的链接输出是随机输出的..不是和左图中对应输出结果的..
我自己还单步执行了 Command1_Click() 执行完到了 Inet1_StateChanged 的索引变成了40...(不解,我不太懂事件流程)
求解......代码有点长,,希望大家认真看下哦..
[code=VB][/code]
Private Sub Command1_Click()
On Error Resume Next
If Text1.Text = "" Then
MsgBox "不能为空"
Exit Sub
End If
For i = 0 To List1.ListCount - 1
Load Inet1(i)
Inet1(i).Cancel
Inet1(i).Proxy = List1.List(i)
Inet1(i).Execute Text1.Text, "get"
ProgressBar1.Value = i
Label3.Caption = i
Next
End Sub
Private Sub Command2_Click()
CommonDialog1.Filter = "文本|*.txt"
CommonDialog1.InitDir = App.Path
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
List1.Clear
Dim S As String
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, S
List1.AddItem S
Loop
Close
Label1.Caption = "总数: " & List1.ListCount
End If
End Sub
Private Sub Form_Load()
Text1.Text = "www.baidu.com"
End Sub
Private Sub Inet1_StateChanged(Index As Integer, ByVal State As Integer)
On Error Resume Next
Debug.Print Index
If State = 11 Then
a = Inet1(Index).GetHeader
a = Mid(a, 1, InStr(1, a, vbCrLf))
List2.AddItem List1.List(Index) & " 连接错误 " & a
Inet1(Index).Cancel
Unload Inet1(Index)
ProgressBar1.Value = ProgressBar1.Value + 1
Label2.Caption = "已连接了: " & List2.ListCount & "个"
ElseIf State = 12 Then
a = Inet1(Index).GetHeader
a = Mid(a, 1, InStr(1, a, vbCrLf))
List2.AddItem List1.List(Index) & " 连接成功 " & a
Inet1(Index).Cancel
Unload Inet1(Index)
ProgressBar1.Value = ProgressBar1.Value + 1
Label2.Caption = "已连接了: " & List2.ListCount & "个"
End If
End Sub