Private Sub Command1_Click()
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.RemoteHost = "time.nist.gov"
Winsock1.RemotePort = 13
Winsock1.LocalPort = 0
Winsock1.Connect
End Sub
Private Sub Winsock1_Close()
If Winsock1.State <> 0 Then
Winsock1.Close
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim temp As String
Dim sTimeArray() As String
Dim currentDate As Date
Dim currentTime As Date
Dim lReturn As Long
temp = String(bytesTotal, " ")
Winsock1.GetData temp, vbString, bytesTotal
End Sub
通过上面简单的步骤就可以得到标准的时钟,比如我写这个测试例子得到的是