<% Function GetNextOrderNumberAmended(strOrderNumber) ' if ordernumber has no word 'amended' at the end, append 'amended 1' ' if has 'amended %n' at the end, calculate %n+1 and append that to the ordernumber If InStr(LCase(strOrderNumber), "amended") Then intAmendNum = CInt(Split(LCase(strOrderNumber), " amended ")(1)) GetNextOrderNumberAmended = Split(LCase(strOrderNumber), " amended ")(0) & " amended " & CStr(intAmendNum + 1) Else GetNextOrderNumberAmended = strOrderNumber & " amended 1" End If End Function Function GetNextOrderNumber(strOrderNumber, arrDBSimilarOrderNumbers) ' called by ordersplit.asp ' gets the next avaiable orderNumber after the passed orderNumber ' if the order number has ' amended ' in it, save the tail part and re-glue it on at the end Dim strNextOrderNumber, arrBits arrBits = Split(strOrderNumber, " amended ") If UBound(arrBits) = 0 Then ' we dont have ' amended ' in the ordernumber If not isNull(arrDBSimilarOrderNumbers) Then GetNextOrderNumber = arrBits(0) & Chr(Asc(Replace(arrDBSimilarOrderNumbers(1,UBound(arrDBSimilarOrderNumbers,2)), arrBits(0), "")) + 1) Else GetNextOrderNumber = arrBits(0) & "A" End If Else ' we dont have ' amended ' in the ordernumber If not isNull(arrDBSimilarOrderNumbers) Then GetNextOrderNumber = arrBits(0) & Chr(Asc(Replace(arrDBSimilarOrderNumbers(1,UBound(arrDBSimilarOrderNumbers,2)), arrBits(0), "")) + 1) & " amended " & arrBits(1) Else GetNextOrderNumber = arrBits(0) & "A" & " amended " & arrBits(1) End If End If End Function %> <% strOrderNumber = "10" %>

<%= GetNextOrderNumberAmended(strOrderNumber) %>

<% strOrderNumber = "10 amended 1" %>

<%= GetNextOrderNumberAmended(strOrderNumber) %>

<% arrbits = split("17A amended 1", " amended ") %> <%= UBound(arrbits) & "::" & arrbits(0) %>
<%= GetNextOrderNumber("17 amended 1", null) %>
<% arrbits = split("17A", " amended ") %> <%= UBound(arrbits) & "::" & arrbits(0) %>