Scripting 为什么这总是给我现在的时间

Scripting 为什么这总是给我现在的时间,scripting,vbscript,Scripting,Vbscript,我得到了输入框,无论输入什么值,它都会给出当前时间。 我希望默认值保持当前时间(显示),但如果用户将其更改为另一个值,则我希望更改后的值 更新代码 If internal_isTurnedOn And Right(LCase(internal_CurrentUser), 8) = "lastname" Then Dim value: value = CDate(InputBox("enter the date and time (hh:mm)", "pleas

我得到了输入框,无论输入什么值,它都会给出当前时间。 我希望默认值保持当前时间(显示),但如果用户将其更改为另一个值,则我希望更改后的值

更新代码

    If internal_isTurnedOn And Right(LCase(internal_CurrentUser), 8) = "lastname"  Then     
        Dim value: value = CDate(InputBox("enter the date and time (hh:mm)", "please", FormatDateTime(Time, 4)))     
        ' validate the input here     
        internal_Time = CDate(value)  
    Else
        internal_Time = CDate(Time)
    End If  

然而,现在我得到了正确的时间,我已经输入,但它添加了一些额外的不需要的东西,如秒和上午/下午。不管怎样,只是为了以军用格式获取时间?

嗯,我尝试了你的代码,只要得到提示,我就可以设置时间。你确定以后在你的代码中没有重置它吗

可以肯定的是,如果:

    If internal_isTurnedOn And Right(LCase(internal_CurrentUser), 8) = "lastname"  Then
        Dim value
        value = CDate(InputBox("Please enter the time (hh:mm)", "Time Input", FormatDateTime(Now, 4)))             
        internal_Time = CDate(FormatDateTime(value, 4))
    Else
        internal_Time = FormatDateTime(Time, 4)
    End If  
要将时间返回为军事时间,不使用AM/PM,请使用以下命令:

msgbox(internal_Time)
可能是你的情况 如果internal_设置为On和Right(LCase(internal_CurrentUser),则8)=“lastname”将始终返回false
检查你的情况

我调试了它,我得到了输入框。这是一个很好的猜测,但肯定还有别的原因。我打赌它与FormatDateTime(Time,4)有关,然后可能会检查代码的另一部分,该部分正在重置内部_时间变量。要获得军事时间,请将第4行更改为:internal_Time=FormatDateTime(CDate(value),4)
internal_Time = FormatDatetime(CDate(value), 4)