I copied this code from another post, and I'm now getting this error:
Expected ';'
File:script.js
Line:38
Sub updateDateDiff
Can you help?
Here's the code:
function msoxd_my_Date2::OnAfterChange(eventObj)
{
if (eventObj.IsUndoRedo)
{
return;
}
Sub updateDateDiff
Dim fromDate
Dim toDate Dim days
Dim daysNode
set daysNode = XDocument.DOM.selectSingleNode("/my:myFields/my:DaysRemaining")
fromDate = Trim(XDocument.DOM.selectSingleNode("/my:myFields/my:Date").text)
toDate = Trim(XDocument.DOM.selectSingleNode("/my:myFields/my:Date2").text)
if Len(fromDate) = 0 Or Len(toDate) = 0
Then daysNode.text = "n/a"
else
fromDate = CDate(fromDate)
toDate = CDate(toDate)
days = DateDiff("d", fromDate, toDate)
' Determine whether the xsi:nil attribute is set for this
' element. If so, remove the xsi:nil attributes so that
' the value can be set.
if Not IsNull(daysNode.getAttribute("xsi:nil")) then daysNode.removeAttribute("xsi:nil")
end if
daysNode.text = CStr(days)
end if
}
Thanks.