![]() ![]() Private static bool _ValidateFedE圎xpressCheckDigit( string trackingNumber)Ĭhar trackingNumberArray = new char 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) Calculate x to be (running total modulo 10).Calculate n to be (ASCII value of character - 48).Calculate n to be (2 * the numeric value of the character).If the character is in an even position (e.g., 2 nd, 4 th, 6 th.), then:.Calculate x to be ((2 * n) - (9 * INT( n/5))) where INT( n/5) returns n/5 rounded down to the next integer (e.g., 34.3 would be 34, but 34.8 would also be 34).If the character is numeric, then add the numeric value to the running total.If the character is in an odd position (e.g., 1 st, 3 rd, 5 th.), then:.Examine each character in the sequence:.Then, you'll see the method below the outline: ![]() Next, let me take a moment to outline the algorithm used to generate the check digit. To do this, we drop the "1Z" portion, and only use the last 15 characters in the method.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |