'############################################################################### ' By N.A. ' For MXN Systems Only 'XPd 'X can be any number 'Pd=D,W,M or Y 'Examples '5D==>5 Days '5==>5 Months '5.0==> 5Years '############################################################################### Sub TestForm_OnLoad() Dim IO Set IO = GetObject("","Cubes.IScriptCubeIO") Rows=IO.GetInputCubeRows(0)-1 TN=IO.GetInputCubeCell(1,0).GetValueDouble() For i = 0 to Rows RawString=IO.GetInputCubeCell(0,i).GetValueText() 'Default settings StringPdType="M" StringPd=RawString IF IsNumeric(RawString) then IF InStr(RawString,".") > 0 then StringPdType="Y" End If Else 'Is String ON/TN/SP/Spot ? In MXN Spot/TN are the same If (RawString = "ON" OR RawString = "TN" OR RawString = "Spot" OR RawString = "SN") Then Select Case UCase(RawString) Case "ON" StringPd = -1 Case "TN" StringPd = 0 Case "Spot" StringPd = 0 Case "SN" StringPd = 1 Case Else StringPd = 0 End Select StringPdType = "D" 'msgbox("RawString = #" & RawString & "# StringPd = " & StringPd) Else StringPd=Left(RawString,Len(RawString)-1) StringPdType=Right(RawString,1) End If 'msgbox("RawString: " & RawString & " StringPd: " & StringPd) End if 'msgbox("TN: " & TN & " StringPd: " & StringPdType) Select Case UCase(StringPdType) Case "D" Result=TN+StringPd Case "W" Result=TN+StringPd * 7 Case "M" Result=TN+StringPd * 28 Case "Y" Result=TN+StringPd * 364 Case Else Result=0 End Select 'msgbox("Result: " & Result-TN) IO.GetOutputCubeCell(0,i).SetValueText(CDate(Result)) Next End Sub