

Return _ValidateFedExGroundCheckDigit(trackingNumber) Return _ValidateUPSCheckDigit(trackingNumber) Įlse if (courierName = CourierName.FedExGround) Return _ValidateFedE圎xpressCheckDigit(trackingNumber) Įlse if (courierName = CourierName.UPS) // UPS method If (courierName = CourierName.FedE圎xpress) // fedex express method TrackingNumber = Regex.Replace(trackingNumber, ", " ").ToUpper() Public static bool IsValid( string trackingNumber, CourierName courierName) Return IsValid(trackingNumber, GetCourier(trackingNumber)) Public static bool IsValid( string trackingNumber) Public static CourierName GetCourier( string trackingNumber) If( Int32.TryParse(ch.ToString(), out testodd) = true) Int asciivalue = 32(ch) Įlse // Indicates character in odd position If( Int32.TryParse(ch.ToString(), out testeven) = true) If((charindex % 2) = 0) // Indicates character in even position // UPS Check Digit Calculation Method // private int CalculateCheckDigit( String trk)


The next 2 characters denote the service type:.The next 6 characters we fill with our UPS account number "XXXXXX".This is up to you, as only two portions are required by UPS, the rest you can make up on your own. For information sake, I will describe how the company I work for generates tracking numbers. It takes a 15 character sequence, in this case a string, and calculates the check digit using this sequence. This method leaves the rest of the tracking number up to you.

The input for the method is a string, but you could rework it to use a raw char if wish.
#Ups freight tracking by number code#
The following code is a generic method that can be used to calculate a check digit for a UPS Tracking Number. I thought I would make it a bit easier for others by describing it here. It took me a while to figure this out, researching mostly. This article serves to describe the algorithm used to calculate a UPS Tracking Number.
