📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1440
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 1440
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.ComboBox cboHost
Height = 315
ItemData = "Form1.frx":0000
Left = 120
List = "Form1.frx":0002
Style = 2 'Dropdown List
TabIndex = 1
Top = 120
Width = 4455
End
Begin VB.CommandButton cmdPing
Caption = "Ping"
Height = 375
Left = 1920
TabIndex = 0
Top = 960
Width = 855
End
Begin VB.Label lblIPAddress
BorderStyle = 1 'Fixed Single
Height = 315
Left = 120
TabIndex = 2
Top = 480
Width = 4455
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' See:
' How to ping an IP address with Visual Basic by using ICMP
' http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b300197
Option Explicit
Private m_IpAddresses As Collection
Private Sub cboHost_Click()
lblIPAddress.Caption = m_IpAddresses(cboHost.ListIndex + 1)
End Sub
Private Sub cmdPing_Click()
Dim Reply As ICMP_ECHO_REPLY
Dim lngSuccess As Long
Dim strIPAddress As String
Screen.MousePointer = vbHourglass
DoEvents
Debug.Print "****************************************"
'Get the sockets ready.
If SocketsInitialize() Then
'Address to ping
strIPAddress = lblIPAddress.Caption
'Ping the IP that is passing the address and get a reply.
lngSuccess = ping(strIPAddress, 5000, Reply)
'Display the results.
Debug.Print "Address to Ping: " & strIPAddress
Debug.Print "Raw ICMP code: " & lngSuccess
Debug.Print "Ping Response Message : " & EvaluatePingResponse(lngSuccess)
Debug.Print "Time : " & Reply.RoundTripTime & " ms"
'Clean up the sockets.
SocketsCleanup
Else
'Winsock error failure, initializing the sockets.
Debug.Print WINSOCK_ERROR
End If
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Load()
Set m_IpAddresses = New Collection
cboHost.AddItem "www.google.com"
m_IpAddresses.Add "64.233.167.99"
cboHost.AddItem "www.amazon.com"
m_IpAddresses.Add "207.171.166.102"
cboHost.AddItem "msdn.microsoft.com"
m_IpAddresses.Add "207.46.248.109"
cboHost.AddItem "Localhost"
m_IpAddresses.Add "127.0.0.1"
cboHost.AddItem "Invalid"
m_IpAddresses.Add "0.0.0.0"
cboHost.ListIndex = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -