Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vb.net操作当前时间的文本框_Vb.net - Fatal编程技术网

vb.net操作当前时间的文本框

vb.net操作当前时间的文本框,vb.net,Vb.net,如何操作文本框编辑如何加载表单检查时间并向用户提供要使用的文本框 例如,当 我想我需要的逻辑是这样的 if its4pm then textbox.text ="its 4 pm" else if its10pm then textbox.text = "its 10 pm" end if 我认为这很简单,但我觉得很困惑 我尝试了这个,但它给了我一个输出错误 Dim date1 As Date = #7:00:00 AM# Dim date2 As Date = #10:00:

如何操作文本框编辑如何加载
表单
检查时间并向用户提供要使用的文本框

例如,当

我想我需要的逻辑是这样的

if its4pm then
textbox.text ="its 4 pm"
else if its10pm then
textbox.text = "its 10 pm"
end if
我认为这很简单,但我觉得很困惑

我尝试了这个,但它给了我一个输出错误

    Dim date1 As Date = #7:00:00 AM#
    Dim date2 As Date = #10:00:00 AM#
    Dim date3 As Date = #1:00:00 PM#
    Dim date4 As Date = #4:00:00 PM#
    Dim date5 As Date = #7:00:00 PM#

 If TimeOfDay = date5 Then
        TextBox1.Text = "here"
        TextBox6.Text = "here"
    ElseIf TimeOfDay = date4 Then
        TextBox2.Text = "here"
        TextBox7.Text = "here"
    ElseIf TimeOfDay = date3 Then
        TextBox3.Text = "here"
        TextBox8.Text = "here"
    ElseIf TimeOfDay = date2 Then
        TextBox4.Text = "here"
        TextBox9.Text = "here"
    ElseIf TimeOfDay = date1 Then
        TextBox5.Text = "here"
        TextBox10.Text = "here"
    End If
编辑:我说的输出错误是if-else不工作,即使它不给我语法错误
文本框
不显示
“here”
立即使用.Hour.ToString()


我不确定你想达到什么目的,但我想简单地格式化当前日期时间会简单得多。我试着转换为字符串日期。但当我在
if-else
时,我得到了字符串错误和无法比较的日期。是这样的,你想在你的文本框上显示当前(系统)日期时间吗?不,我想让表单加载来检查时间,并为用户提供要使用的文本框,而不是使用几个文本框(一个用于特殊时间)-使用一对文本框,并根据时间改变它们的行为?你能展示/说出你为什么使用不同的文本框吗?
If Now.Hour.ToString() = "7" Then
     'code
End If