注册 登录
编程论坛 VB6论坛

请教个时间控制的问题

a414715440 发布于 2011-09-07 19:08, 400 次点击
如果说我要在某段时间到某段时间,例如:19:01-19:02我有两个文本框供用户输入时间段,然后有一个按钮,按下按钮执行某操作,应该怎么云写这段时间,

怎么用代码呢
4 回复
#2
创造奇迹2011-09-07 21:21
MsgBox Now > CDate(Date & " 19:01") And Now < CDate(Date & " 19:02")
要注意把:全角的冒号替换成:
'
text1=replace(text1,"",":")
text2=replace(text2,"",":")
MsgBox Now > CDate(Date & " " & text1) And Now < CDate(Date & " " & text2)



这样就可以识别一个时间是否处于该区间内
#3
a4147154402011-09-08 09:09
回复 2楼 创造奇迹
Private Sub Command1_Click()
Text1 = Replace(Text1, ":", ":")
Text2 = Replace(Text2, ":", ":")
MsgBox Now > CDate(Date & " " & Text1) And Now < CDate(Date & " " & Text2)




If CDate(Date & " 9:06") And Now < CDate(Date & " 9:07") Then
Timer1.Interval = 1000
End If
end sub
 这样可以吗
#4
a4147154402011-09-08 09:29
回复 2楼 创造奇迹
我知道了,
用下面的代码就可以了,
Private Sub Command1_Click()
Text1 = Replace(Text1, ":", ":")
Text2 = Replace(Text2, ":", ":")


If Text1 > (Date & " 9:06") And Text2 < CDate(Date & " 9:07") Then


Timer1.Interval = 1000
End If


End Sub
#5
e3bnsd2012-12-02 20:23
  正在找这方面的资料。
1