| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 739 人关注过本帖
标题:试用期的代码,哪个大侠最完善一下
取消只看楼主 加入收藏
ymhy12345
Rank: 2
等 级:论坛游民
帖 子:83
专家分:36
注 册:2011-8-27
结帖率:72.73%
收藏
 问题点数:0 回复次数:0 
试用期的代码,哪个大侠最完善一下
程序代码:
'先引用Microsoft XML, v6.0
Option Explicit

Private Sub Form_Load()
On Error GoTo GetDateErr

Dim myXmlHttp As XMLHTTP
Set myXmlHttp = New XMLHTTP

myXmlHttp.open "GET", "http://m.baidu.com", False
myXmlHttp.send
Dim BaiduNow As Date


 BaiduNow = DateFromHTTP(myXmlHttp.getResponseHeader("Date"))

 BaiduNow = DateAdd("h", 8, BaiduNow)

 

MsgBox BaiduNow
Exit Sub
GetDateErr:
MsgBox "获取网络时间错误, 请确认已连接到网络"

End





End Sub
Public Function DateFromHTTP(HTTPDate As String) As Date

Const GMTDiff = 0

Dim Swd As String, d As String, Sm As String, Y As String, h As String, m As String, s As String, g As String, Out As Date
HTTPDate = LCase$(HTTPDate)

If Mid$(HTTPDate, 27, 3) = "gmt" Then
Swd = Left$(HTTPDate, 3)
d = Mid$(HTTPDate, 6, 2)
Sm = Mid$(HTTPDate, 9, 3)

Y = Mid$(HTTPDate, 13, 4)
h = Mid$(HTTPDate, 18, 2)
m = Mid$(HTTPDate, 21, 2)
s = Mid$(HTTPDate, 24, 2)
'    on error resume Next
 Out = DateSerial(Y, mFromSm(Sm), d) + TimeSerial(h, m, s) '+ GMTDiff

End If
DateFromHTTP = Out


End Function


Function mFromSm(Sm As String) As Integer

Dim Out As Integer
Select Case LCase$(Sm)

Case "jan": Out = 1: Case "feb": Out = 2: Case "mar": Out = 3: Case "apr": Out = 4

Case "may": Out = 5: Case "jun": Out = 6: Case "jul": Out = 7: Case "aug": Out = 8



 Case "sep": Out = 9: Case "oct": Out = 10: Case "nov": Out = 11: Case "dec": Out = 12

 


End Select
mFromSm = Out










End Function















2012-12-29 18:06
快速回复:试用期的代码,哪个大侠最完善一下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018963 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved