ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Bar Code control
  • Overview
  • Displaying a bar code in a Bar Code control
  • Displaying a bar code in a Bar Code control
  • Retrieving in a Bar Code control the value read by a specific device
  • Retrieving the value of the bar code displayed in the Bar Code control
  • Properties specific to Bar Code controls
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Handling Bar Code controls programmatically
Overview
WINDEV, WEBDEV and WINDEV Mobile allow you to programmatically handle Bar Code controls. To do so, use the variable of the Bar Code control in the code.
The variable of the Bar Code control corresponds to the name of the control. This variable is a text variable.
Displaying a bar code in a Bar Code control

Displaying a bar code in a Bar Code control

To display a bar code in a Bar Code control, simply assign a value.
For example:
  • direct assignment:
    BAC_BarCodeControl = "123456789"
  • assignment using a variable:
    BAC_BarCodeControl = Products.BarCode
QR Codes:
To display a QR code in a Bar Code control, you can use a variable of type BarCode.
AndroidiPhone/iPad For example:
// Decode a QR Code
MyQRCode is BarCode
MyQRCode = BCCapture()
IF ErrorOccurred = False THEN
BAC_MyBarCodeControl = MyQRCode
END
Remark: In a window or page, if the control is bound to a data file item, the entered value is automatically retrieved using ScreenToFile or PageToFile. For more details, see Binding Bar Code controls to items.
WINDEV

Retrieving in a Bar Code control the value read by a specific device

You can read the bar codes and display the corresponding value on the screen. To read a bar code:
  1. Connect a specific device to the serial port of your computer.
  2. Read the bar code value using the following serial port management functions:
    sOpenOpens and initializes:
    • a serial port.
    • a parallel port.
    • an infrared port.
    sReadReads a character string in the entry buffer of the specified serial port.
  3. Initialize the read value in a Bar Code control corresponding to the type of bar code read.
Example used to read a bar code with a specific device connected to the COM1 serial port:
// Declare the variables
// Define the number of characters that must be read
NbCharToRead is int = 13
// Number of pending bytes in the buffer
NbPendingBytes is int
BufferPrn is string // Content of the buffer
SerialPort is int = 1 // Serial port COM1
 
// Open and initialize the serial port COM1
IF sOpen(SerialPort, 5000, 5000) THEN
// Read the bar code
// Retrieve the number of pending bytes
NbPendingBytes = sInEntryQueue(SerialPort)
// Retrieve the value of the bar code only
// if at least 13 characters have been read
IF NbPendingBytes >= NbCharToRead THEN
BufferPrn = sRead(SerialPort, NbPendingBytes)
// Retrieve the first 13 characters read
BufferPrn = Left(BufferPrn, 13)
// Display the bar code value in the
// "EDT_BarCode" edit control
EDT_BarCode = BufferPrn
END
END
Retrieving the value of the bar code displayed in the Bar Code control
WINDEVUniversal Windows 10 App To retrieve the bar code value:
  • perform a simple assignment.
    For example:
    BarCodeValue = BAC_BarCodeControl
  • retrieve part of the value.
    For example:
    BeginningBarCode = Left(BAC_BarCodeControl, 3)
  • use the Value property.
Remark: If the control is bound to a data file item, the value entered in the control is automatically updated in the data source using ScreenToFile. For more details, see Binding Bar Code controls to items.
Properties specific to Bar Code controls
The following properties can be used to programmatically handle Bar Code controls.
DndSourceGets and sets the behavior of the source control during a drag-and-drop operation.
DndTargetGets and sets the behavior of the target control during a drag-and-drop operation.
HorizontalAlignmentGets and sets the horizontal alignment of a Bar Code control.
VerticalAlignmentGets and sets the vertical alignment of a Bar Code control.


For a complete list of the WLanguage properties that can be used with a Bar Code control, see Bar Code control properties.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/24/2023

Send a report | Local help