DroidDB Tip of the Month

DroidDB® Tip for March 2015

Converting a Barcode Value to a Number

When DroidDB reads a barcode, the barcode is a text string. You might want to convert it to a number (perhaps to validate that it is in a certain range of numbers). DroidDB doesn't have an explicit convert function, but it can be done.

When DroidDB evaluates an addition expression, it first converts the two arguments to numbers and then adds them. So, a string with two characters (a '1' and a '2') plus another string with two characters (a '3' and a '4')

    '12' + '34'

evaluates to a numeric value of 46.

When DroidDB evaluates a concatenation expression, it first converts the two arguments to strings and then adds them. So, the numeric value 12 concatentated with the numeric value 34

    12 & 34

evaluates to a string '1234'

So, to convert a scanned value to a number, just add 0 to it:

    MyBarcode + 0

 

Back to List »

Visit our store

Top rated! I needed a solid database application development tool for mobile devices. I chose DroidDB for Android OS because it provided a way to get a strong product to market quickly. DroidDB is relational, gives me control over form layout, handles macros, and supports events. It works on all Android versions I have tried and is a great companion product to SYWARE’s VisualCE.

Mark Read, President
SyntegraTech, Inc.

signup for our newsletter