Kofax - Padding Zeros to an Index Field Value
Applies to
Kofax Capture Version All
Summary
I want to have an Index Field that must have 5 numbers and not strip out leading zeros. How can this be done in a Validation script?
Answer/Solution
You can implement the IFormatProvider parameter of the ToString function as follows:
Private Sub Name0_FieldPostProcessing(sender As Object, e As PostFieldEventArgs) Handles Name0.FieldPostProcessing
Name0.IndexField.Value = CInt(Name0.IndexField.Value).ToString("D5")
End Sub
This only works with numerical input from the user so, you will need to check that an actual number was entered. Any other character will throw an exception.
CInt converts the input string to an Integer.
The "D5" passed to the ToString function tells it to format the integer to pad zeros at the left of the string to full length of five characters.
CASO Knowledge Base