0
我有一個問題:VBA函數不能返回值主副
現在,我得到一個日期範圍主要子(20160706-20160805),我有分開的價值,並把它作爲一個日期。我要做的就是:
Main sub date()
Dim strDaterage as string
Dim startdate as date
'For the sake of simplicity, just use the hard code for the date
strDaterange = "20160706-20160805"
startdate = findstartdate()
msgbox (startdate)
End sub
而對於功能分隔日期的提取值:
Function findstartdate()
daterange = "20160706-20160805"
startDateange = Left(daterange, 8)
startYear = Left(startDateange, 4)
startMonth = Mid(startDateange, 5, 2)
startDay = Right(startDateange, 2)
startdate = DateSerial(startYear, startMonth, startDay)
End Function
我嘗試使用ByVal和byfer,但它仍然無法正常工作。我如何將日期值返回到主子?
非常感謝提前!
你不會從你的函數返回任何東西。你錯過了這一行:'findstartdate = startdate' –
這也行得通,非常感謝=) –