vb dim急 !!在线等!!2次发.上次没明白,你们在看看好不

来源:百度知道 编辑:UC知道 时间:2024/05/23 23:32:30
Private Sub Command1_Click()
Dim a As Integer
For a = 1 To 254
Shell "cmd /c ping 192.168.0." & a & ">c:\" & a & ".txt"
Next a
End Sub
就可以,但是一次要开254个CMD,电脑都快死机了

Private Sub Command1_Click()
Dim a As Integer
For a = 1 To 254
Shell "cmd /c ping 192.168.0." & a & ">>c:\1.txt"
Next a
End Sub
为什么这样就不行了啊
!!不知道怎么和你们在这里谈,方便留QQ吗,也不知道怎么给你们积分,最好你们说详细点,我刚刚学的!!

上次不是告诉地你,不能直接用SHELL吗?
像你这种FOR调用,前一个Shell并没正式完成下一个及下下一个都又运行了,你无法知道最终什么时候真正完成向文件内写内容都完成,这样不乱套了吗?
我现在没时间,一会给你按你的思路写一个正确的给你帖上。不过按你的思路径,循环完254个得半小时。

=========================================================

不允许重复回答呀!
以下是按你的想法写的,效率可能不高,因为循环254个网络连接本来就要消耗大量时间也不怪,用其它方法也快不到哪去!
帖在这的代码可复制粘帖后可以直接运行。

以下代码请写在一个模块内:监测调用的程序运行是否完成

Option Explicit
Public Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Public Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessI