Public?Function?GetBeijingTime()?As?DateTime
Dim?dt?As?DateTime
Dim?wrt?As?WebRequest?=?Nothing
Dim?wrp?As?WebResponse?=?Nothing
Try
wrt?=?WebRequest.Create("")
wrp?=?wrt.GetResponse()
Dim?html?As?String?=?String.Empty
Using?stream?As?Stream?=?wrp.GetResponseStream()
html?=?sr.ReadToEnd()
End?Using
Dim?tempArray?As?String()?=?html.Split(";"c)
For?i?As?Integer?=?0?To?tempArray.Length?-?1
tempArray(i)?=?tempArray(i).Replace(vbCr?vbLf,?"")
Next
Dim?year?As?String?=?tempArray(1).Split("="c)(1)
dt?=?DateTime.Parse(year?"-"?month?"-"?day?"?"?hour?":"?minite?":"?second)
Catch?generatedExceptionName?As?WebException
Catch?generatedExceptionName?As?Exception
Finally
If?wrp?IsNot?Nothing?Then
wrp.Close()
End?If
If?wrt?IsNot?Nothing?Then
wrt.Abort()
End?Try
Return?dt
End?Function
now() 可以获取当前的时间.
可以使用 print now() 进行测试.输出当前时间.
想用文本保存.
那就:
open app.path "\time.txt" for output as #1
print #1,now()
close
可以获取中国科学院国家授时中心的标准时间(即中国北京时间).
你可以借用vb的inet控件从中科院的网站上获取,中科院网站是:
vb中获取系统当前的时间用函数 now() 就可以.另外还有相关的时间 date() time()
Private Sub Command1_Click()
MsgBox Now()
MsgBox Time()
MsgBox Date
End Sub
以上就是土嘎嘎小编为大家整理的vb.net获取北京时间的简单介绍vb.net获取北京时间的简单介绍相关咨询咨询主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!