如何用vb代码在文本框中显示当前时间是上午或下午
3个回答
推荐于2016-10-27
展开全部
Private Sub Command1_Click()
Dim s As Date
Dim bs As String
s = Now
Select Case Hour(s)
Case Is < 8
bs = "凌晨"
Case Is < 12
bs = "上午"
Case Is < 14
bs = "中午"
Case Is < 17
bs = "下午"
Case Else
bs = "晚上"
End Select
Label1.Caption = Format(s, "YYYY年MM月DD日 hh:mm:ss " & bs & " 星期" & Choose(Weekday(s), "日", "一", "二", "三", "四", "五", "六"))
End Sub
Dim s As Date
Dim bs As String
s = Now
Select Case Hour(s)
Case Is < 8
bs = "凌晨"
Case Is < 12
bs = "上午"
Case Is < 14
bs = "中午"
Case Is < 17
bs = "下午"
Case Else
bs = "晚上"
End Select
Label1.Caption = Format(s, "YYYY年MM月DD日 hh:mm:ss " & bs & " 星期" & Choose(Weekday(s), "日", "一", "二", "三", "四", "五", "六"))
End Sub
展开全部
举个例子:按下数字1将文本框内容变为“你按下了1”:
private
sub
textbox1_keypress(keyascii
as
integer)
if
keyascii
=
asc("1")
textbox1.text="你按下了1"
else
textbox1.text="你按下的不是1"
end
if
end
sub
private
sub
textbox1_keypress(keyascii
as
integer)
if
keyascii
=
asc("1")
textbox1.text="你按下了1"
else
textbox1.text="你按下的不是1"
end
if
end
sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Format(Time, "ampm")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询