编写一个定时提醒的程序。要求可以输入任意的时间,当时间到了自动提醒。请参考例子。 20
提示:(1)获取计算机的当前时间,可用TimeOfDay函数(2)把当前时间显示为时分秒格式:TimeOfDay.ToString("HH:mm:ss"),显示为时分格式...
提示:(1)获取计算机的当前时间,可用 TimeOfDay 函数(2)把当前时间显示为时分秒格式:TimeOfDay.ToString("HH:mm:ss"),显示为时分格式: TimeOfDay.ToString("HH:mm")(3)s.SubString(0,5)表示截取字符串s的左边5个字符下面是我写的,不知道哪儿错了,不能弹窗出来,求大神指正!Public Class Form1 Dim t As Date Dim s As String Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label4.Text = "现在的时间是" & TimeOfDay.ToString("HH:mm:ss") If TimeOfDay.ToString("HH:mm:ss") = t Then MsgBox(TextBox1.Text, TextBox2.Text) ListBox1.Items.Add("已提醒") End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Items.Add(TextBox2.Text) TextBox1.Clear() TextBox2.Clear() Dim t1 As Integer, t2 As Integer, t3 As Integer, t As Date t1 = Val(TextBox1.Text.Substring(0, 2)) t2 = Val(TextBox1.Text.Substring(3, 2)) t3 = Val(TextBox1.Text.Substring(6, 2)) If 0 <= t1 < 24 Then t1 = t.Hour If 0 <= t2 <= 59 Then t2 = t.Minute If 0 <= t3 <= 59 Then t3 = t.Second End SubEnd Class
(图片是要求的效果) 展开
(图片是要求的效果) 展开
1个回答
展开全部
If 0 <= t1 < 24 Then t1 = t.Hour
If 0 <= t2 <= 59 Then t2 = t.Minute
If 0 <= t3 <= 59 Then t3 = t.Second
改成
If 0 <= t1 < 24 Then t.Hour=t1
If 0 <= t2 <= 59 Then t.Minute=t2
If 0 <= t3 <= 59 Then t.Second= t3
If 0 <= t2 <= 59 Then t2 = t.Minute
If 0 <= t3 <= 59 Then t3 = t.Second
改成
If 0 <= t1 < 24 Then t.Hour=t1
If 0 <= t2 <= 59 Then t.Minute=t2
If 0 <= t3 <= 59 Then t.Second= t3
更多追问追答
追问
不行啊,改了它说格式不对啊
追答
1、这两句不要
'TextBox1.Clear()
'TextBox2.Clear()
2、Dim t1 As Integer, t2 As Integer, t3 As Integer, t As Date
去掉 ,t AS date
3、If 0 <= t1 < 24 Then t1 = t.Hour
If 0 <= t2 <= 59 Then t2 = t.Minute
If 0 <= t3 <= 59 Then t3 = t.Second
改成
If (0 <= t1 < 24) And (0 <= t2 <= 59) And (0 <= t3 <= 59) Then
t = CDate(t1 & ":" & t2 & ":" & t3)
End If
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询