注册 登录
编程论坛 VB6论坛

试用期的代码,哪个大侠最完善一下

ymhy12345 发布于 2012-12-29 18:06, 739 次点击
程序代码:
'先引用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















2 回复
#2
happy123j2013-01-01 13:28
代码不写,但我可以给你说一下如何实现
首先,你需要创建两个Text,分别命名为:text1、Text2
然后,你需要在一个隐蔽让用户不易找到的地方——C:\windows下,创建文件夹放两个txt
然后得用四个通用对话框(Microsoft Common Dialog Control 6.0)
创建一个窗口,名字叫做 第一次 。
在创建一个窗口,叫做 已过期
然后,程序一运行,用通用对话框打开TXT1的内容到Text1
如果是空的,就转到第一次
第一次把父窗口的Text1内容更改为 1,用通用对话框保存
第一次在用代码查看今天的日期,保存到txt2
打开txt2,获取今天的日期
什么时候日期值+使用天数后,等于过期的天数,那么转到 已过期,注明试用期已过。
懂了么?
#3
li867911772013-01-10 20:00
我也想搞个时间间隔脚本 获取网络时间不会 楼主动能说说BaiduNow = DateFromHTTP(myXmlHttp.getResponseHeader("Date"))
BaiduNow = DateAdd("h", 8, BaiduNow)
这两句的意思吗、
1