How to increase number of characters when reading data from

Posted by Ahmedsa under C# on 2/23/2017 | Points: 10 | Views : 1414 | Status : [Member] | Replies : 2
I work in windows from c# vs 2015

i read data from scanner bar code reader directly to my windows

without using text box box but i face problem

i need to increase number of character when receiving to 200 character

so that how to increase that please ?

code below working success but it read only 13 character

i need to increase it to 200 character or less so that how ?
public partial class Form1 : Form
{
DateTime _lastKeystroke = new DateTime(0);
List<char> _barcode = new List<char>(10);
public Form1()
{
InitializeComponent();
}



private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
TimeSpan elapsed = (DateTime.Now - _lastKeystroke);
if (elapsed.TotalMilliseconds > 100)
_barcode.Clear();

_barcode.Add(e.KeyChar);
_lastKeystroke = DateTime.Now;

if (e.KeyChar == 13 && _barcode.Count > 0)
{
string msg = new String(_barcode.ToArray());

label1.Text = msg;
_barcode.Clear();
}
}
}
}

so that code above can read but 13 character only

i need to increase it to 200 character or less .

bar code scanner is working as USB keyboard as HID keyboard read qr code




Responses

Posted by: Rajnilari2015 on: 2/23/2017 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
Try
e.KeyChar == 125


ASCII 125 = }

If you want to loop through, then try this

int min = 0;
int max = 128;
for (int i = min; i < max; i++)
{
if (e.KeyChar == i && _barcode.Count > 0)
{
.................
...................
}
}


--
Thanks & Regards,
RNA Team

Ahmedsa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ahmedsa on: 2/24/2017 [Member] Starter | Points: 25

Up
0
Down
thank you for reply
i change key char from 13 to 125 but it not work for me
so that what i do now

Ahmedsa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response