vb获取分钟&设置时间&变量类型
其实我想要的是分别获取时,分,秒,不知有冇代码呀?要求:先分别获取时分秒,然后把分加上1再设置一遍时间,这样系统时间就变成了原先的时间加一分钟,谁会代码呀?告诉我呀!!呵...
其实我想要的是分别获取时,分,秒,不知有冇代码呀?
要求:
先分别获取时分秒,然后把分加上1再设置一遍时间,这样系统时间就变成了原先的时间加一分钟,谁会代码呀?告诉我呀!!
呵呵,vb6.0和.net都可以.最好是测试过的.
我自己也尝试写了,可是明明分钟加一以后再用设置时间函数设置的时候.就提示变量类型不符,况且不能单独设置分钟!
要是高手使用api或者模块一定要讲清楚,什么代码放在哪里,复制来的不要.
快,最后限在明天呀,我真着急,10月31号之前! 展开
要求:
先分别获取时分秒,然后把分加上1再设置一遍时间,这样系统时间就变成了原先的时间加一分钟,谁会代码呀?告诉我呀!!
呵呵,vb6.0和.net都可以.最好是测试过的.
我自己也尝试写了,可是明明分钟加一以后再用设置时间函数设置的时候.就提示变量类型不符,况且不能单独设置分钟!
要是高手使用api或者模块一定要讲清楚,什么代码放在哪里,复制来的不要.
快,最后限在明天呀,我真着急,10月31号之前! 展开
1个回答
2013-04-17
展开全部
Option Explicit
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Dim time As SYSTEMTIME
Private Sub Command1_Click()
Dim hour As Integer
hour = txttime(3) - 8 'Beijing Time
With time
.wYear = txttime(0).Text
.wMonth = txttime(1).Text
.wDay = txttime(2).Text
.wHour = IIf(hour > 0, hour, hour + 24) 'set universal time
.wMinute = txttime(4).Text
.wSecond = txttime(5).Text
End With
SetSystemTime time
End Sub
Private Sub Form_Load()
GetSystemTime time
With time
txttime(0).Text = .wYear
txttime(1).Text = .wMonth
txttime(2).Text = .wDay
txttime(3).Text = .wHour + 8 'Beijing Time
txttime(4).Text = .wMinute
txttime(5).Text = .wSecond
End With
End Sub
对不起哈时间晚了你自己加一下调用时再加也行!
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Dim time As SYSTEMTIME
Private Sub Command1_Click()
Dim hour As Integer
hour = txttime(3) - 8 'Beijing Time
With time
.wYear = txttime(0).Text
.wMonth = txttime(1).Text
.wDay = txttime(2).Text
.wHour = IIf(hour > 0, hour, hour + 24) 'set universal time
.wMinute = txttime(4).Text
.wSecond = txttime(5).Text
End With
SetSystemTime time
End Sub
Private Sub Form_Load()
GetSystemTime time
With time
txttime(0).Text = .wYear
txttime(1).Text = .wMonth
txttime(2).Text = .wDay
txttime(3).Text = .wHour + 8 'Beijing Time
txttime(4).Text = .wMinute
txttime(5).Text = .wSecond
End With
End Sub
对不起哈时间晚了你自己加一下调用时再加也行!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询