Anyone got code to convert a long 10 digit UPC code to a short 6 digit one?

I've written code to convert short UPC to long if it helps any looks something like this:

If Mid(cUPC, 7, 1) < "3" Then

'//if ends in "012"

'//expand as 1-2,8-10th

cUPC = "00" + Mid(cUPC, 2, 2) + Mid(cUPC, 7, 1) + "0000" + Mid(cUPC, 4, 3)

ElseIf Mid(cUPC, 7, 1) = "3" Then

'//if ends in "3"

'//expand as 1-3,9-10th

cUPC = "00" + Mid(cUPC, 2, 3) + "00000" + Mid(cUPC, 5, 2)

ElseIf Mid(cUPC, 7, 1) = "4" Then

'//if ends in "4"

'//expand as 1-4,10th

cUPC = "00" + Mid(cUPC, 2, 4) + "00000" + Mid(cUPC, 6, 1)

Else

'//must end in "5678 or 9"

'//expand as UPC 1-5,10th

cUPC = "00" + Mid(cUPC, 2, 5) + "0000" + Mid(cUPC, 7, 1)

End If

This code assumes the 6 digit code has leading and trailing system and check digit already added and operates on the 2-7 digit to expand six to ten plus leading country code (assumed zero) and system digit also zero and checkdigit makes 13 when done.

Question is I want to go the other way and this is giving me a headache trying to reverse this code :)

Increasing points for a really good payout to anyone motivated or who can locate this code for us!