在popup的input框中将短date转换为长date
我有下面的代码popup框要求date例如:2013年4月5日,我如何自动将其转换为长date格式?
我试过了
strUserResponse = FormatDateTime(Date, vbLongDate)
但这只是给我今天的日子
谢谢
Public Function AskForDeadline() As String Dim strUserResponse As String strUserResponse = InputBox("Enter attribute_5: Survey Deadline - In Short Date Format Ex: 4/9/2012 Will convert to LOND date AUTOMATICALLY") strUserResponse = FormatDateTime(Date, vbLongDate) ActiveSheet.Cells(2, 9).Value = strUserResponse 'the 2, 9 is the cell reference for I2 - row 2, column 9. End Function
正如我在之前的文章中提到的那样, Inputbox
不是获取date的最佳方式,但是如果您仍然想要继续这一操作,那么请改变
strUserResponse = FormatDateTime(Date, vbLongDate)
至
strUserResponse = FormatDateTime(strUserResponse, vbLongDate)
您正在获取当前date,因为您在该行代码中将Date
转换为今天的date。