Reputation: 9541
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
I get the input box and no matter what value I enter, it gives me the current time. I want the default to remain the current time (displayed) but if the user changes it to another value then I want the changed value
UPDATE TO CODE
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
However now I am getting the correct time that I've inputted but it is adding some extra unwanted things like seconds and AM/PM. Anyway to just get the time in military format?
Upvotes: 0
Views: 91
Reputation: 11263
Hmmm, I tried your code and as long as I got the prompt, I could set the time. Are you sure it's not getting reset somewhere later in your code?
Just to be sure, can you put something like this right after the End if:
msgbox(internal_Time)
To return the time as just military time, without AM/PM, use this:
internal_Time = FormatDatetime(CDate(value), 4)
Upvotes: 1
Reputation:
probably your condition If internal_isTurnedOn And Right(LCase(internal_CurrentUser), 8) = "lastname" would be returning false always chk your condition
Upvotes: 0