You need to use the AddMonths method of the Date class. This should get you started:
Once you enter the number of months for the contract, the code will produce the date by using the AddMonths method.
Public Sub field2_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)
' Write your code here to change the main data source.Dim DOM As XPathNavigator = MainDataSource.CreateNavigator()
' Create reference to date pickerDim datePickerNode As XPathNavigator = DOM.SelectSingleNode("/my:myFields/my:field1", NamespaceManager)
' remove nil attribute from node
DeleteNil(datePickerNode)
' Create reference to contract monthsDim contractMonthsNode As XPathNavigator = DOM.SelectSingleNode("/my:myFields/my:field2", NamespaceManager)
' Create reference to contract end dateDim contractEndDate As XPathNavigator = DOM.SelectSingleNode("/my:myFields/my:field3", NamespaceManager)
' remove nil attribute from node
DeleteNil(contractEndDate)
' get the valuesDim contractDate As Date = datePickerNode.ValueAsDateTime()
Dim contractMonths As Integer = contractMonthsNode.ValueAsInt()
' do the math and return values
contractEndDate.SetValue(contractDate.AddMonths(contractMonths).ToShortDateString)
End Sub
' The following sub is required to work with dates!!
Public Sub DeleteNil(ByVal node As XPathNavigator)
If (node.MoveToAttribute( _
"nil", "http://www.w3.org/2001/XMLSchema-instance")) Then
node.DeleteSelf()
End If
End Sub