Search code examples
c#opos

How can the following ScanDataLabel output be reduced to the price?


A barcode reader provides me with the following string of numbers which is displayed in a text box 7612345203508. In the string of numbers is the price at the following place 76123452(0350)8 Now I want to display it with a dot like in this example 761234520350 Fr. 03.50

How can I represent this correctly?

My code looks like this:

VS2010 C#

textBox1.Text = axOPOSScanner1.ScanDataLabel; //Preis
textBox1.Text += "\t" + "Fr." +  axOPOSScanner1.ScanDataLabel.Remove( 0, 8 );

The output: 7612345203508 Fr.03508

Thanks


Solution

  • This should do the trick for this example:

    textBox1.Text += "\t" + "Fr. " + axOPOSScanner1.ScanDataLabel.Substring(8, 2) + "." + axOPOSScanner1.ScanDataLabel.Substring(10, 2);
    

    But take into account that longer ScanDataLabel or shorter won't give you the correct numbers or throw an ArgumentOutOfRangeException.