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)
精彩评论