vb编程题1.在窗体上创建一个文本框,当单击文本框时,文本框中轮流显示当前日期及当前时间。用vb怎么编程?
展开全部
在窗体上添加一个文本框、一个时钟空间,代码如下:
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
Text1.Text = ""
End Sub
Private Sub Text1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static N As Integer
N = N + 1
If N Mod 2 = 1 Then Text1.Text = Date Else Text1.Text = Time
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
Text1.Text = ""
End Sub
Private Sub Text1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static N As Integer
N = N + 1
If N Mod 2 = 1 Then Text1.Text = Date Else Text1.Text = Time
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询