VB如何在单击窗体时在各TEXT中显示当前时间.

2024-12-25 15:28:01
推荐回答(2个)
回答1:

Private Sub Form_Click()
Text1.Text = Year(Date)
Text2.Text = Month(Date)
Text3.Text = Day(Date)
Text4.Text = "星期" & GetWD(Weekday(Date))
Text5.Text = Format$(Time, "hh:mm:ss")
End Sub
Function GetWD(ByVal Week As Integer) As String
Select Case Week
Case 1
GetWD = "日"
Case 2
GetWD = "一"
Case 3
GetWD = "二"
Case 4
GetWD = "三"
Case 5
GetWD = "四"
Case 6
GetWD = "五"
Case 7
GetWD = "六"
End Select
End Function

搞定了

回答2:

Private Sub Form1_Click()
    Text1.Text = Now
End Sub