我有一个与设备相关的 vbscript 问题。下面的代码甚至不应该在之后执行,i = playercount
但确实如此。
Do Until i = playercount
If i = playercount then
Exit Do
end if
Select Case True
Case i >=1 And i <= 4
'usb hubs 1-4
'b = i + 1
If pluggedindev(4) = False Then
msgbox(i)
msgbox(playercount)
Set ExtHubPort(i) = ExtHub(1).Ports(i)
Wscript.Sleep 2000
ExtHubPort(i).HotPlug GenericHIDDSFDev(i)
WScript.Sleep 10000
pluggedindev(i) = True
MsgBox("usb device (ports 1-4)")
'else if playercount <= 4 then
'Exit Do
End If
Case i >=5 And i <= 8
'usb hubs 5-8
Wscript.sleep 2000
For b = 1 To 4
Set ExtHubPort(i) = ExtHub(2).Ports(b)
Wscript.sleep 2000
ExtHubPort(i).HotPlug GenericHIDDSFDev(i)
WScript.Sleep 10000
'Log("Usb devices 1 through 4 set")
Next
'usb hubs 9-12
Case i >=9 And i <= 12
For b = 1 To 4
Set ExtHubPort(i) = ExtHub(3).Ports(b)
Wscript.sleep 2000
ExtHubPort(i).HotPlug GenericHIDDSFDev(i)
WScript.Sleep 10000
Next
'usb hubs 13-16
Case i >=13 And i <= 16
For b = 1 To 4
Set ExtHubPort(i) = ExtHub(4).Ports(b)
Wscript.sleep 2000
ExtHubPort(i).HotPlug GenericHIDDSFDev(i)
WScript.Sleep 10000
Next
'usb hubs 17-20
Case i >=17 And i <=20
For b = 1 To 4
Set ExtHubPort(i) = ExtHub(5).Ports(b)
Wscript.sleep 2000
ExtHubPort(i).HotPlug GenericHIDDSFDev(i)
WScript.Sleep 10000
Next
End Select
i = i + 1
Loop
有人看看,看看为什么?似乎 i 下标超出范围并导致问题,但显然上面的代码应该可以工作。