Find the largest value in a field of a table

SOLVED

Hi everyone, 

Does anyone know the fastest way to find the largest value in a number field using User-Defined Script/VBS?

Background: I'm working on creating a unique ID, like GTIN/UPC, for each item code as the item codes are generated.  To get things automated, I'm using a UDT, with ItemCode as the key, which gets populated on successful Post_Table_Write event in CI_Item, then automatically generating a portion of the UPC (6 digit integer) using RecordCount function, finally a check digit is concatenated to everything else and it'll be the value of the UPC field.  It works, but when anything but the very last record in the UDT gets deleted, the next UPC will be a duplicated number.  So if I could find the largest value in the 6 digit partial UPC field instead of the record count, then I could easily solve the problem.  I could also have a boolean field to indicate obsolescence if a record in CI_Item gets deleted, and that would actually solve most of the problem except running out of numbers unless a huge numbers of existing items get renumbered, or entered and entered by error.  But that's unlikely and doesn't solve my intellectual endeavor :) 

Whether it's a number or string, i think this kind of scripts are very portable and useful since we can't just call a MAX function.   Anyone have an experience with this or thoughts?

Ken

EDIT-----

After David and Kevin kindly responded.  I realized that my question really had 2 implications.  

1) how to sort returned values (asked in the main title/main question)

2) how to get an accurate next number regardless deletions of existing records (strongly implied in the Background part)

David perfectly answered #1 and added supplement info with CI_NextNumber class

Kevin perfectly answered #2

Kevin, sorry i have to mark David answer solely because of the title.  But please know that i truly appreciate you reading into what i might benefit from!!