网站首页 > 文章中心 > 其它

vb.net获取北京时间的简单介绍

作者:小编 更新时间:2023-09-06 15:07:31 浏览量:222人看过

vb.net 获取互联网的北京时间

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

如何用VB获取北京时间

now() 可以获取当前的时间.

可以使用 print now() 进行测试.输出当前时间.

想用文本保存.

那就:

open app.path "\time.txt" for output as #1

print #1,now()

close

用VB怎么获取标准北京时间啊?

可以获取中国科学院国家授时中心的标准时间(即中国北京时间).

你可以借用vb的inet控件从中科院的网站上获取,中科院网站是:

vb怎么获取系统当前的系统时间啊

vb中获取系统当前的时间用函数 now() 就可以.另外还有相关的时间 date() time()

Private Sub Command1_Click()

MsgBox Now()

MsgBox Time()

MsgBox Date

End Sub

vb怎么获取北京时间

以上就是土嘎嘎小编为大家整理的vb.net获取北京时间的简单介绍vb.net获取北京时间的简单介绍相关咨询咨询主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章