1 Public stringGETCODE128A (stringinputdata)2 {3 stringresult ="";4 intChecksum =103;5 intj =1;6 for(intII =0; II < inputdata.length; ii++)7 {8 if(Inputdata[ii] >= +)9 {TenChecksum + = (Inputdata[ii]- +) * (ii +1); One } A Else - { -Checksum + = (Inputdata[ii] + -) * (ii +1); the } - } -Checksum = checksum%103; - if(Checksum < the) + { -Checksum + = +; + } A Else at { -Checksum + = -; - } -result = Convert.tochar (203) + inputdata.tostring () + Convert.tochar (checksum) + Convert.tochar (206); - returnresult; - } in - Copy Code to + code128b - the * Copy Code $ Public stringGETCODE128B (stringinputdata)Panax Notoginseng { - stringresult =""; the intChecksum =104; + intj =1; A for(intII =0; II < inputdata.length; ii++) the { + if(Inputdata[ii] >= +) - { $Checksum + = (Inputdata[ii]- +) * (ii +1); $ } - Else - { theChecksum + = (Inputdata[ii] + -) * (ii +1); - }Wuyi } theChecksum = checksum%103; - if(Checksum < the) Wu { -Checksum + = +; About } $ Else - { -Checksum + = -; - } Aresult = Convert.tochar (204) + inputdata.tostring () + Convert.tochar (checksum) + Convert.tochar (206); + returnresult; the } - $ Copy Code the the code128c the the - Copy Code in Public Static stringGETCODE128C (stringinputdata) the { the stringresult =""; About intChecksum = the; the intj =1; the for(intII =0; II < inputdata.length; ii++) the { + if(ii%2==0) - { theChecksum + = Convert.ToInt32 (inputdata.substring (II,2)) *J;Bayi if(Convert.ToInt32 (inputdata.substring (II,2)) < the) the { theResult + = Convert.tochar (Convert.ToInt32 (inputdata.substring (II,2)) + +); - } - Else the { theResult + = Convert.tochar (Convert.ToInt32 (inputdata.substring (II,2)) + -); the } theJ + +; - } theii++; the } theChecksum = checksum%103;94 if(Checksum < the) the { theChecksum + = +; the }98 Else About { -Checksum + = -;101 }102result = Convert.tochar (205) + result + Convert.tochar (checksum) + Convert.tochar (206);103 returnresult;104}
Reprint code generated Barcode 2.