VB高手帮我看看代码怎么不行了?

来源:百度知道 编辑:UC知道 时间:2024/06/25 12:52:13
我这个是时间校对的代码,以前就可以用,现在一运行就弹出几个命令框.不知是那里错了.帮忙看看,谢谢了. 最好能帮成我改永远都可以用.

Dim a, b, c, x, y
Private Sub Command1_Click()
WebBrowser1.Navigate "http://bjtime.cn/"
End Sub
Private Sub webbrowser1_documentcomplete(ByVal pDisp As Object, URL As Variant)
Dim time As String
Dim day As String
Dim m As String
Dim n As String
z = WebBrowser1.Document.body.innertext
x = Mid(z, InStr(z, "2009"), 9)
y = Mid$(z, InStr(z, "农历") + 7, 8)
a = Split(x, "年") 'a(0)为年
b = Split(a(1), "月") 'b(0)为月
c = Split(b(1), "日") 'c(0)为日
Label1.Caption = "标准北京时间的:" & a(0) & "-" & b(0) & "-" & c(0) & " " & y
s = a(0) & "-" & b(0) & "-" & c(0) & " " & y
If s <> "" Then
time = y
day = a(0) & "-&

Dim i
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.timedate.cn/worldclock/ti.asp"
i = 0
End Sub
Private Sub Timer1_Timer()
i = i + 1
If i = 3 Then
a = WebBrowser1.Document.body.innertext
s = Mid(a, InStr(a, "服务器时间:") + 1, 25)
x = Split(s, "星期")
Shell "cmd /c time " & Mid(x(1), 3, 8)
Shell "cmd /c date " & FormatDateTime(x(0))
Timer1.Enabled = False
End If
End Sub

Private Sub webbrowser1_documentcomplete(ByVal pDisp As Object, URL As Variant)
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub

因为调整时间使用的网站http://bjtime.cn/做了调整,利用你的代码,截取到的日期和时间就变成错误的了。我刚才将你以上的代码,做了如下修改,测试通过,供参考。
Dim a, b, c, x, y
Private Sub Command1_Click()
WebBrowser1.