2013-04-27 57 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