开发者

This code snippet isn't working as expected (VBScript)

开发者 https://www.devze.com 2023-03-28 12:55 出处:网络
Dim value value = CDate(InputBox(\"Please enter the time (hh:mm)\", \"Time Input\", FormatDateTime(Now, 4)))
        Dim value
        value = CDate(InputBox("Please enter the time (hh:mm)", "Time Input", FormatDateTime(Now, 4)))          
        ' validate the input here
        WScript.Echo value
        internal_Time = CDate(FormatDateTime(value, 4))
开发者_如何学编程

I am expecting the time to be as 08:24 or 13:12 but it's appearing as 8:26:12 AM


Here:

internal_Time = CDate(FormatDateTime(value, 4))

Your formatting to a string but then converting back to a Date, so the formatting is lost and the value is converted to a VB Date value that includes AM/PM, if its for display then just store the string:

internal_Time = FormatDateTime(value, 4)
0

精彩评论

暂无评论...
验证码 换一张
取 消