I am using VB .Net to access the eBay API and store all completed orders in a database. This database is then fed into a proprietary shipping system, which can not handle an order number larger than 20 characters. eBay returns an order number like so 230407279314-680141236013
which is too long. The order number is always 12 numbers a hyphen and 12 more numbers. What I need to do, is turn this (the result can be alpha numerical) into a shorter, unique order key to store in my database alongside the true orderId (so that this can be referenced by the shipping software instead of the actual order number). The reason for the 20 character limit is the barcode algorithm used. Is there any way to achieve this in VB .Net 2010? This number can be anything unique, so long as it does not exist already (even a good uniqueid function would work, but I would have to query the database to make sure it isn’t taken)
2
Answers
You could store it as one unique hex number – say you’ve stored the ebay code as two strings: lefstr ‘-‘ rightstring. So in this case leftstring = ‘230407279314’ and rightstring = ‘680141236013’.
once you’ve put them into a single string and retrieved the integer value from it you should be able to store it as a string in hex: id.toString(“x”)
the id will be no more than 20 hexadecimal characters long 🙂
You can actually turn that number into a 20 character string. You can split the numbers into six digit numbers. As each of those only need 20 bits to be stored, you can then represent them as a five digit hexadecimal number:
Which would give the 20 character string:
Do it like this: