怎么在vb中调用ping命令,并将ping的过程显示在vb界面中,就是把运行——>ping 192.

怎么在vb中调用ping命令,并将ping的过程显示在vb界面中,就是把运行——>ping 192.168.1.1 的dos界面嵌入到 所写的vb界面中?语句注明解释最好,谢谢

第1个回答  2012-08-15
添加一个文本框
Set objShell = CreateObject("WScript.Shell")
Set objWshScriptExec = objShell.Exec("ping 192.168.6.242")
Set objStdOut = objWshScriptExec.StdOut
Do Until objStdOut.AtEndOfStream
strLine = objStdOut.ReadLine
Text1.Text = Text1.Text & strLine & vbNewLine
Loop追问

能解释下每句的具体意思吗,谢谢,(函数的说明)

追答

'首先创建一个WScript.Shell对象
'
'然后给它执行ping语句
'
'将cmd程序打开并执行

循环取出cmd执行出来的每一行记录,并且将每一行赋值给text1,直到结束

...将ping的过程显示在vb界面中,就是把运行——>ping 192.
添加一个文本框 Set objShell = CreateObject("WScript.Shell")Set objWshScriptExec = objShell.Exec("ping 192.168.6.242")Set objStdOut = objWshScriptExec.StdOut Do Until objStdOut.AtEndOfStream strLine = objStdOut.ReadLine Text1.Text = Text1.Text & strLine & vbNewLine Loop ...

vb怎么实现ping,并将ping结果搞到手。
Dim pid As Long pid = Shell("cmd.exe \/C Ping " & Text1.Text & " > c:\\r.txt", vbHide) ' 提示 Text2.Text = "正在执行Ping " & Text1.Text & " ..." '等待Shell执行结束 Dim hProc As Long hProc = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid) ...

VB调用PING命令
下面这个是Ping 的脚本 成功返回true 不成功返回false Public Function Pings(strMachines As String) As Boolean aMachines = Split(strMachines, ";")For Each machine In aMachines Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus w...

如何在vb中使用ping?
Dim pid As Long pid = Shell("cmd.exe \/C Ping " & Text1.Text & " > c:\\r.txt", vbHide) ' 提示 Text2.Text = "正在执行Ping " & Text1.Text & " ..." '等待Shell执行结束 Dim hProc As Long hProc = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid) ...

如何在VB中执行类似ping的命令
'请把代码 PingCode.bas 添加到你的程序模块中,然后在你的程序中加入以下代码即可:Private Sub Command1_Click() Dim iReply As Long, sAddress As String sAddress = "192.168.1.1" iReply = Ping(sAddress) If iReply > 0 Then 'Ping通后的代码 Else 'Ping不通...

如何在VB中使用PING命令
'标准模块Option ExplicitPublic Const IP_STATUS_BASE = 11000Public Const IP_SUCCESS = 0Public Const IP_BUF_TOO_SMALL = (11000 + 1)Public Const IP_DEST_NET_UNREACHABLE = (11000 + 2)Public Const IP_DEST_HOST_UNREACHABLE = (11000 + 3)Public Const IP_DEST_PROT_UNREACHABLE = (...

VB如何调用ping命令来判断是否联网!?
首先添加一模块,代码如下 Option Explicit Private Const IP_SUCCESS As Long = 0 Private Const IP_STATUS_BASE As Long = 11000 Private Const IP_BUF_TOO_SMALL As Long = (11000 + 1)Private Const IP_DEST_NET_UNREACHABLE As Long = (11000 + 2)Private Const IP_DEST_HOST_UNREACHABLE ...

用VB.NET怎么编一个ping的程序
Net.NetworkInformation.PingReply = m_ping.Send("192.168.1.1", 1000)'设置为自己要ping的ip地址 If m_PingReply.Status = Net.NetworkInformation.IPStatus.Success Then MsgBox(m_PingReply.RoundtripTime)'返回网络延迟 Else'返回不通的原因 MsgBox(m_PingReply.Status.ToString)End If ...

VB 怎么实现ping
以下是Ping 模块代码:Option Explicit 'Ping 模块,用法:PingIP("202.108.22.142", TTL(可选,默认10), TimeOut(可选,默认1000)),返回延时时长 '注意:不能ping域名。Private Type ip_option_information TTL As Byte 'Time To Live Tos As Byte 'Type Of Service Flags As Byte 'IP ...

vb调用ping命令检测网络
添加一个textbox控件 代码如下:运行即可得到目的 Public Function CmdPing(ByVal strIp As String) As String Dim p As New Process '创建一个线程 p.StartInfo.FileName = "cmd.exe"p.StartInfo.UseShellExecute = False p.StartInfo.RedirectStandardInput = True p.StartInfo.RedirectStandardOutput ...

相似回答