以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]怎么通过代码计算网速  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=88587)

--  作者:新航程小何
--  发布时间:2016/8/5 11:54:00
--  [求助]怎么通过代码计算网速
各位老师,我在做软件测试的时候,发现如果有事网络不好,但没有断开,我的网络判定是断开就提示错误,但是这样网络不好,没法判定,所有我想能不能测出网速大小,然后判定网络。请教怎么做呢?
--  作者:大红袍
--  发布时间:2016/8/5 12:03:00
--  

试试

 

Dim p As new Process()
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False \'关闭Shell的使用
p.StartInfo.RedirectStandardInput = True \'重定向标准输入
p.StartInfo.RedirectStandardOutput = True \'重定向标准输出
p.StartInfo.RedirectStandardError = True \'重定向错误输出
p.StartInfo.CreateNoWindow = True \'设置不显示窗口
p.Start()
p.StandardInput.WriteLine("ping www.baidu.com")
p.StandardInput.WriteLine("exit")

Dim str As String = p.StandardOutput.ReadToEnd()
msgbox(str)


Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "(?<=平均 = )[0-9]+")
If mc.count = 0 Then
    msgbox("连不上")
Else
    msgbox(mc(0).value)
End If


--  作者:kylin
--  发布时间:2016/8/5 14:54:00
--  
收藏,不错!谢谢大红袍兄!
--  作者:lhpc120
--  发布时间:2017/8/12 16:42:00
--  
收藏