C # generate UPC-A code

Source: Internet
Author: User

Because the recent work used to upc-a code, so the study of the next, the first simple introduction of the next UPC-A code

UPC code is a barcode made by the United States Uniform Codes Commission, which is mainly used in the United States and Canada, and we can see it in the United States imports of goods. UPC code (Universal Product code) is the first large-scale application of the bar code, its characteristics is a fixed length, continuous bar code, is currently used mainly in the United States and Canada, due to its wide range of applications, it is called universal barcode. UPC code can only be used to represent numbers, so its loadline set is a digital 0~9.

The main formats are as follows:


Upc-a

Flag, vendor code, product code needs to be related to the relevant departments to apply, the check code is generated according to the preceding code, generating rules as follows:

From the country code start from left to right to take the number, set upc-a code code is as follows:

n1n2n3n4n5n6n7n8n9n10n11c
Then the calculation steps of the check code are as follows:

C1 = n1+ N3+n5+n7+n9+n11

C2 = (N2+N4+N6+N8+N10) x3

CC = (C1+C2) take single digit

C (check code) = 10–CC (if the value is 10, take 0)

C # generates the code for the check code as follows:

        //Assuming that the flag code is 7, the manufacturer code is 08502, the incoming product code can generate a upc-a code        Private Const stringCode ="708502";  Public stringGETCODEUPC (stringNumber ) {            stringStrcode = code +Number ; intC1 =int. Parse (strcode[Ten]. ToString ()) +int. Parse (strcode[8]. ToString ()) +int. Parse (strcode[6]. ToString ()) +int. Parse (strcode[4]. ToString ()) +int. Parse (strcode[2]. ToString ()) +int. Parse (strcode[0].            ToString ()); intC2 = C1 *3; intC3 =0+int. Parse (strcode[1]. ToString ()) +int. Parse (strcode[3]. ToString ()) +int. Parse (strcode[5]. ToString ()) +int. Parse (strcode[7]. ToString ()) +int. Parse (strcode[9].            ToString ()); intC4 = c2 +C3; intc =Ten-C4%Ten; if(c = =Ten) C =0; stringUPC = Strcode +c.tostring (); returnUPC; }

C # generate UPC-A code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.