MsgBox "网络时间:" & Format(GetText, "yyyymmdd")
它这里获得的是格林威治时间,把它加上八小时就是北京时间了:
MsgBox "现在时间:" & Format(CDate(GetText) + #8:0:0#, "yyyy-mm-dd hh:nn:ss")
format(now,"yyyy/MM/dd")
直接输出now就是系统要输出的格式,format是输出格式的,然后now为要输出的数据。后面为输出格式。你想要什么格式自己可以去设置
这样改行吗
Private Sub Command3_Click()
Dim sj As String
Dim SS As String
sj = Format(Now, "hhmmss")
SS = "HEADCLK" & sj & "0D0A"
Text7Text = SS
End Sub
在vb中要做到微秒级的计时,用api:QueryPerformanceFrequency和QueryPerformanceCounter
不过用这种方法有时会罢工。。。自己按实际情况决定吧。。。。
用这个,你可以改一下,试试看吧!
Option Explicit
' 声明函数
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long
' 声明结构
Private Type LARGE_INTEGER
LowPart As Long
HighPart As Long
End Type
Private Sub Form_Load()
Dim PFrequency As LARGE_INTEGER
' 获得高精度运行计数器的频率
QueryPerformanceFrequency PFrequency
' 延时 1000微妙
SleepEx (PFrequencyLowPart / 1000000) 1000, 0
End Sub
' 实现延时功能
Private Function SleepEx(ByVal LowPart As Long, HighPart As Long) As Long
Dim Interval As LARGE_INTEGER
Dim Privious As LARGE_INTEGER
Dim Current As LARGE_INTEGER
' 获得高精度运行计数器的数值
Call QueryPerformanceCounter(Privious)
Current = Privious
IntervalLowPart = LowPart
IntervalHighPart = HighPart
' 通过比较两次计数器的数值的差实现精确延时
Do While (Abs((CurrentHighPart 2 ^ 16) + CurrentLowPart) _
- Abs(PriviousHighPart 2 ^ 16) + PriviousLowPart) < _
(Abs(IntervalHighPart 2 ^ 16) + IntervalLowPart)
Call QueryPerformanceCounter(Current)
Loop
SleepEx = 0
End Function
以上就是关于关于VB中获取网络时间 的问题 满意后给分全部的内容,包括:关于VB中获取网络时间 的问题 满意后给分、Vb.net 2008 如何获取网络时间、有关VB获取系统时间并显示的问题等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)