2013-04-27 58 views
0

我有一个弹出框询问日期的代码如下:4/5/2013,如何自动将其转换为长日期格式?在弹出输入框中将短日期转换为长日期输入框

我试图

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 

回答

2

正如我在以前的文章中提到的是Inputbox没有得到一个最好的方式日期但如果你仍然想继续这个,然后改变

strUserResponse = FormatDateTime(Date, vbLongDate) 

strUserResponse = FormatDateTime(strUserResponse, vbLongDate) 

你得到,因为你是在该行的代码,这将给你今天的日期转换Date当前日期。

+0

感谢以上。我无法弄清楚如何以“更好的方式”将日期分配给特定的单元格 – xyz 2013-04-27 20:19:44