📄 form1.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form Form1
Caption = "网络时间同步"
ClientHeight = 3720
ClientLeft = 3864
ClientTop = 3960
ClientWidth = 5292
LinkTopic = "Form1"
ScaleHeight = 3720
ScaleWidth = 5292
Begin VB.OptionButton timezone
Caption = "马 加 丹"
Height = 375
Index = 11
Left = 3360
TabIndex = 15
Top = 2280
Width = 1092
End
Begin VB.OptionButton timezone
Caption = "悉 尼"
Height = 375
Index = 10
Left = 3360
TabIndex = 14
Top = 1800
Width = 1092
End
Begin VB.OptionButton timezone
Caption = "东 京"
Height = 375
Index = 9
Left = 3360
TabIndex = 13
Top = 1320
Width = 1092
End
Begin VB.OptionButton timezone
Caption = "北 京"
Height = 375
Index = 8
Left = 3360
TabIndex = 12
Top = 960
Value = -1 'True
Width = 1092
End
Begin VB.OptionButton timezone
Caption = "曼 谷"
Height = 375
Index = 7
Left = 2160
TabIndex = 11
Top = 2280
Width = 1092
End
Begin VB.OptionButton timezone
Caption = "达 卡"
Height = 375
Index = 6
Left = 2160
TabIndex = 10
Top = 1800
Width = 1092
End
Begin VB.OptionButton timezone
Caption = "伊斯兰堡"
Height = 375
Index = 5
Left = 2160
TabIndex = 9
Top = 1320
Width = 1092
End
Begin VB.OptionButton timezone
Caption = "阿布扎比"
Height = 375
Index = 4
Left = 2160
TabIndex = 8
Top = 960
Width = 1092
End
Begin VB.Timer hourly_check
Interval = 58500
Left = 4560
Top = 3000
End
Begin VB.OptionButton timezone
Caption = "莫 斯 科"
Height = 255
Index = 3
Left = 960
TabIndex = 7
Top = 2280
Width = 1095
End
Begin VB.OptionButton timezone
Caption = "开 罗"
Height = 375
Index = 2
Left = 960
TabIndex = 6
Top = 1800
Width = 975
End
Begin VB.CommandButton gettime
Caption = "同步时间"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.8
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 2040
TabIndex = 5
Top = 2880
Width = 1575
End
Begin VB.OptionButton timezone
Caption = "罗 马"
Height = 255
Index = 1
Left = 960
TabIndex = 4
Top = 1440
Width = 975
End
Begin VB.OptionButton timezone
Caption = "格林尼治"
Height = 375
Index = 0
Left = 960
TabIndex = 2
Top = 960
Width = 1092
End
Begin VB.Timer get_time
Interval = 58500
Left = 3840
Top = 3000
End
Begin VB.TextBox Text1
Height = 375
Left = 1200
TabIndex = 0
Top = 0
Width = 3852
End
Begin MSWinsockLib.Winsock Winsock1
Left = 4200
Top = 3000
_ExtentX = 593
_ExtentY = 593
_Version = 393216
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "选择时区:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 372
Left = 0
TabIndex = 3
Top = 600
Width = 2292
End
Begin VB.Label Label1
Caption = "数 据"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 0
TabIndex = 1
Top = 120
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim check As Boolean
Dim time_zone As String
Dim minutes As Long
Dim flag As Boolean
Private Sub Form_Load()
time_zone = "北京"
check = False
Winsock1.Connect "207.126.103.204", 13
minutes = 0
flag = False
End Sub
Private Sub gettime_Click()
Winsock1.Connect "207.126.103.204", 13
flag = True
End Sub
Private Sub get_time_Timer()
If Checked = False Then
Winsock1.Connect "207.126.103.204", 13
End If
End Sub
Private Sub hourly_check_Timer()
minutes = minutes + 1
If minutes = 60 Then
Winsock1.Connect "207.126.103.204", 13
End If
End Sub
Private Sub timezone_Click(Index As Integer)
Select Case Index
Case 0: time_zone = "格林尼治"
Case 1: time_zone = "罗马"
Case 2: time_zone = "开罗"
Case 3: time_zone = "莫斯科"
Case 4: time_zone = "阿布扎比"
Case 5: time_zone = "伊斯兰堡"
Case 6: time_zone = "达卡"
Case 7: time_zone = "曼谷"
Case 8: time_zone = "北京"
Case 9: time_zone = "东京"
Case 10: time_zone = "悉尼"
Case 11: time_zone = "马加丹"
End Select
End Sub
Private Sub Winsock1_Connect()
check = True
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim data As String
Winsock1.GetData data
Text1.Text = data
If flag Then
Select Case time_zone
Case "格林尼治":
Me.Caption = Val(Mid(data, 17, 2))
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "罗马":
Me.Caption = Val(Mid(data, 17, 2) + 1)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "开罗":
Me.Caption = Val(Mid(data, 17, 2) + 2)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "莫斯科":
Me.Caption = Val(Mid(data, 17, 2) + 3)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "阿布扎比":
Me.Caption = Val(Mid(data, 17, 2) + 4)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "伊斯兰堡":
Me.Caption = Val(Mid(data, 17, 2) + 5)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "达卡":
Me.Caption = Val(Mid(data, 17, 2) + 6)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "曼谷":
Me.Caption = Val(Mid(data, 17, 2) + 7)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "北京":
Me.Caption = Val(Mid(data, 17, 2) + 8)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "东京":
Me.Caption = Val(Mid(data, 17, 2) + 9)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "悉尼":
Me.Caption = Val(Mid(data, 17, 2) + 10)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
Case "马加丹":
Me.Caption = Val(Mid(data, 17, 2) + 11)
Me.Caption = Me.Caption + _
":" + Mid(data, 20, 5)
End Select
Time = Me.Caption
flag = False
End If
Winsock1.Close
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
check = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -