Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Barcode scanner "datalogic scanner quickscan qd2430 " read the code in text format when i focus any textbox but it decode the code to Decimal(3-digit) if i used evtKeyUpEvent

so, it convert this code "33378755971180" to "051 051 051 055 056 055 053 053 057 055 049 049 056 048"

What I have tried:

private string BarCode = "";
   private void evtKeyUpEvent(object sender, KeyEventArgs e)

   {
       if (Keys.NumPad0 <= e.KeyCode && e.KeyCode <= Keys.NumPad9)
       {
           BuildBarCode((e.KeyCode - Keys.NumPad0).ToString());
       }
       else if (Keys.D0 <= e.KeyCode && e.KeyCode <= Keys.D9)
       {

           BuildBarCode((e.KeyCode - Keys.D0).ToString());
       }
       if (65 <= e.KeyValue && e.KeyValue <= 90)
       {
           BuildBarCode((e.KeyCode).ToString());
       }
       else if (Keys.ShiftKey == e.KeyCode)
       {
       }
       else if (Keys.OemPeriod == e.KeyCode)
       {
           BuildBarCode(".");
       }
       else if (Keys.Multiply == e.KeyCode)
       {
           BuildBarCode("*");
       }
       else if (Keys.Add == e.KeyCode)
       {
           BuildBarCode("+");
       }
       else if (Keys.Separator == e.KeyCode)
       {
           BuildBarCode("|");
       }
       else if (Keys.Subtract == e.KeyCode)
       {
           BuildBarCode("-");
       }
       else if (Keys.Divide == e.KeyCode)
       {
           BuildBarCode("/");
       }
       else if (Keys.OemBackslash == e.KeyCode)
       {
           BuildBarCode(@"\");
       }
       else if (Keys.Separator == e.KeyCode)
       {
           BuildBarCode(",");
       }
       else if (Keys.OemMinus == e.KeyCode)
       {
           BuildBarCode("-");
       }

       else if (Keys.Space == e.KeyCode)
       {
           BuildBarCode(" ");
       }
       else if (Keys.OemCloseBrackets == e.KeyCode)
       {
           BuildBarCode(")");
       }
       else if (Keys.OemOpenBrackets == e.KeyCode)
       {
           BuildBarCode("(");
       }
       else if (Keys.Oemtilde == e.KeyCode)
       {
           BuildBarCode("~");
       }

       else if (Keys.Oemcomma == e.KeyCode)
       {
           BuildBarCode(",");
       }
       else if (Keys.OemSemicolon == e.KeyCode)
       {
           BuildBarCode(";");
       }
       else if (Keys.OemSemicolon == e.KeyCode)
       {
           BuildBarCode(";");
       }


       else if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
       {
           updateUIBarCode(BarCode);
       }
   }
   private void BuildBarCode(string value)
   {
       BarCode = string.Concat(BarCode, value);
   }
   public void updateUIBarCode(string i)
   {
       AddNewRowWithCode(i);
   }
Posted
Comments
0x01AA 20-Dec-23 7:57am    
So it's just the decimal represantation of the ascii codes of your data
Richard MacCutchan 20-Dec-23 8:03am    
It looks like you are converting each number to a decimal representation. Using the debugger will show you exactly what values are being read from the scanner.
Golden Basim 20-Dec-23 8:18am    
it works fine with other scanners. i disn't write any code to decode the text to decimal.
Richard MacCutchan 20-Dec-23 8:33am    
Well where are those results appearing? I see nothing in your code that would display the information you read from the scanner.
Golden Basim 20-Dec-23 8:36am    
i use this function "AddNewRowWithCode(i)" to auto-select the item or show error message "the code "XXXX" doesn't exist

1 solution

It looks like the barcode reader is working is keyboard wedge mode. This means it emulates a keyboard.

Firstly, you are making this difficult for yourself by binding to the KeyUp event. If this is a TextBox then simply look at the Text property when the enter key is pressed and that will have your barcode in it.

If you have to use the KeyUp event then delete most of the code in evtKeyUpEvent, except for checking for the enter key and use a KeysConverter to convert from KeyCode to string.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900