在C# 中对于code39码的44个字符, 用条形扫描枪扫不出来星号(×)和加号(+)?高分求就!!!
码农理财 2008-10-06 01:35:01 private string GetCode39(string strSource)
{
string strEncode = "1001011011010"; //编码字串初值为起始符号
string AlphaBet = @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*"; //Code39的字母
string[] Code39 = {
/*字符*/ /* 条形图案*/ /* 条形编码 */
/* 0 */ "1010011011010", /* 000110100 */
/* 1 */ "1101001010110", /* 100100001 */
/* 2 */ "1011001010110", /* 100100001 */
/* 3 */ "1101100101010", /* 101100000 */
/* 4 */ "1010011010110", /* 000110001 */
/* 5 */ "1101001101010", /* 100110000 */
/* 6 */ "1011001101010", /* 001110000 */
/* 7 */ "1010010110110", /* 000100101 */
/* 8 */ "1101001011010", /* 100100100 */
/* 9 */ "1011001011010", /* 001100100 */
/* A */ "1101010010110", /* 100001001 */
/* B */ "1011010010110", /* 001001001 */
/* C */ "1101101001010", /* 101001000 */
/* D */ "1010110010110", /* 000011001 */
/* E */ "1101011001010", /* 000011001 */
/* F */ "1101011001010", /* 000011001 */
/* G */ "1010100110110", /* 000001101 */
/* H */ "1101010011010", /* 100001100 */
/* I */ "1011010011010", /* 001001100 */
/* J */ "1010110011010", /* 000011100 */
/* K */ "1101010100110", /* 100000011 */
/* L */ "1011010100110", /* 001000011 */
/* M */ "1101101010010", /* 101000010 */
/* N */ "1010110100110", /* 000010011 */
/* O */ "1101011010010", /* 100010010 */
/* P */ "1011011010010", /* 001010010 */
/* Q */ "1010101100110", /* 000000111 */
/* R */ "1101010110010", /* 100000110 */
/* S */ "1011010110010", /* 001000110 */
/* T */ "1010110110010", /* 000010110 */
/* U */ "1100101010110", /* 110000001 */
/* V */ "1001101010110", /* 011000001 */
/* W */ "1100110101010", /* 111000000 */
/* X */ "1001011010110", /* 010010001 */
/* Y */ "1100101101010", /* 110010000 */
/* Z */ "1001101101010", /* 011010000 */
/* - */ "1001010110110", /* 010000101 */
/* . */ "1100101011010", /* 110000100 */
/*' '*/ "1001101011010", /* 011000100 */
/* $ */ "1001001001010", /* 010101000 */
/* / */ "1001001010010", /* 010100010 */
/* + */ "1001010010010", /* 010001010 */
/* % */ "1010010010010", /* 000101010 */
/* * */ "1001011011010" /* 010010100 */ };
strSource = strSource.ToUpper();
for (int i = 0; i < strSource.Length; i++)
{
//查表编码
strEncode = string.Format("{0}{1}", strEncode, Code39[AlphaBet.IndexOf(strSource[i])]);
}
strEncode = string.Format("{0}100101101101", strEncode); //补上结束符号
return strEncode;
}
在水晶报表中定义若个TextObject后。对于字符串序列,当碰到“1”,对应的TextObject背景变黑,当为“0”是,背景变白
string aSequence = "a+9*";
string sequence = GetCode39(aSequence);
for (int i = 0; i < sequence.Length; i++)
{
txtBar = (TextObject)customerReport.ReportDefinition.ReportObjects[textObjName[i]];
if (sequence[i] == '1')
{
txtBar.Border.BackgroundColor = Color.Black;
}
else
{
txtBar.Border.BackgroundColor = Color.White;
}
txtBar.Width = 30;
txtBar.Left = i * 30;
txtBar.Top = 34;
txtBar.Height = 700;
}