Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data

Imports System.Runtime.InteropServices ' needed for DllImport and for Marshal.Copy
Imports System.Text ' needed for StringBuilder Class
Imports System.IO
Imports System.Reflection 'needed for program_file_path


Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents OutputPicture As System.Windows.Forms.PictureBox
    Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents ReadAndModifyButton As System.Windows.Forms.Button
    Friend WithEvents ReadAndExportButton As System.Windows.Forms.Button
    Friend WithEvents CreateAndInsertButton As System.Windows.Forms.Button
    Friend WithEvents ReadSingleFieldButton As System.Windows.Forms.Button
    Friend WithEvents DeleteSingleFieldButton As System.Windows.Forms.Button
    Friend WithEvents RegisterButton As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.OutputPicture = New System.Windows.Forms.PictureBox
        Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        Me.ReadAndModifyButton = New System.Windows.Forms.Button
        Me.ReadAndExportButton = New System.Windows.Forms.Button
        Me.ReadSingleFieldButton = New System.Windows.Forms.Button
        Me.DeleteSingleFieldButton = New System.Windows.Forms.Button
        Me.CreateAndInsertButton = New System.Windows.Forms.Button
        Me.RegisterButton = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'OutputPicture
        '
        Me.OutputPicture.Location = New System.Drawing.Point(8, 8)
        Me.OutputPicture.Name = "OutputPicture"
        Me.OutputPicture.Size = New System.Drawing.Size(368, 256)
        Me.OutputPicture.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
        Me.OutputPicture.TabIndex = 4
        Me.OutputPicture.TabStop = False
        '
        'ReadAndModifyButton
        '
        Me.ReadAndModifyButton.Location = New System.Drawing.Point(152, 280)
        Me.ReadAndModifyButton.Name = "ReadAndModifyButton"
        Me.ReadAndModifyButton.Size = New System.Drawing.Size(120, 32)
        Me.ReadAndModifyButton.TabIndex = 5
        Me.ReadAndModifyButton.Text = "Read and Modify"
        '
        'ReadAndExportButton
        '
        Me.ReadAndExportButton.Location = New System.Drawing.Point(288, 280)
        Me.ReadAndExportButton.Name = "ReadAndExportButton"
        Me.ReadAndExportButton.Size = New System.Drawing.Size(120, 32)
        Me.ReadAndExportButton.TabIndex = 6
        Me.ReadAndExportButton.Text = "Read and Export"
        '
        'ReadSingleFieldButton
        '
        Me.ReadSingleFieldButton.Location = New System.Drawing.Point(16, 320)
        Me.ReadSingleFieldButton.Name = "ReadSingleFieldButton"
        Me.ReadSingleFieldButton.Size = New System.Drawing.Size(120, 32)
        Me.ReadSingleFieldButton.TabIndex = 7
        Me.ReadSingleFieldButton.Text = "Read Single Field"
        '
        'DeleteSingleFieldButton
        '
        Me.DeleteSingleFieldButton.Location = New System.Drawing.Point(152, 320)
        Me.DeleteSingleFieldButton.Name = "DeleteSingleFieldButton"
        Me.DeleteSingleFieldButton.Size = New System.Drawing.Size(120, 32)
        Me.DeleteSingleFieldButton.TabIndex = 8
        Me.DeleteSingleFieldButton.Text = "Delete Single Field"
        '
        'CreateAndInsertButton
        '
        Me.CreateAndInsertButton.Location = New System.Drawing.Point(16, 280)
        Me.CreateAndInsertButton.Name = "CreateAndInsertButton"
        Me.CreateAndInsertButton.Size = New System.Drawing.Size(120, 32)
        Me.CreateAndInsertButton.TabIndex = 0
        Me.CreateAndInsertButton.Text = "Create and Insert"
        '
        'RegisterButton
        '
        Me.RegisterButton.Location = New System.Drawing.Point(288, 320)
        Me.RegisterButton.Name = "RegisterButton"
        Me.RegisterButton.Size = New System.Drawing.Size(120, 32)
        Me.RegisterButton.TabIndex = 9
        Me.RegisterButton.Text = "Register"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(416, 374)
        Me.Controls.Add(Me.RegisterButton)
        Me.Controls.Add(Me.CreateAndInsertButton)
        Me.Controls.Add(Me.DeleteSingleFieldButton)
        Me.Controls.Add(Me.ReadSingleFieldButton)
        Me.Controls.Add(Me.ReadAndExportButton)
        Me.Controls.Add(Me.ReadAndModifyButton)
        Me.Controls.Add(Me.OutputPicture)
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "NIST Library Demo"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private idc_current As Int32
    Private idc As Int32
    Private size_of_byte_array As Int32
    Private byte_array As Byte()
    Private byte_array_ptr As IntPtr
    Private nist_txt_field As String
    Private ptr_nist_txt_field As IntPtr
    Private nist_binary_field As IntPtr
    Private nist_int_field As Int32
    Private type_2_number_of_records As Int32
    Private type_3_number_of_records As Int32
    Private type_4_number_of_records As Int32
    Private type_5_number_of_records As Int32
    Private type_6_number_of_records As Int32
    Private type_7_number_of_records As Int32
    Private type_8_number_of_records As Int32
    Private type_9_number_of_records As Int32
    Private type_10_number_of_records As Int32
    Private type_11_number_of_records As Int32
    Private type_12_number_of_records As Int32
    Private type_13_number_of_records As Int32
    Private type_14_number_of_records As Int32
    Private type_15_number_of_records As Int32
    Private type_16_number_of_records As Int32
    Private type_17_number_of_records As Int32
    Private type_18_number_of_records As Int32
    Private type_19_number_of_records As Int32
    Private type_20_number_of_records As Int32
    Private type_21_number_of_records As Int32
    Private type_22_number_of_records As Int32
    Private type_98_number_of_records As Int32
    Private type_99_number_of_records As Int32
    Private fStream As FileStream
    Private br As BinaryReader
    Private bw As BinaryWriter
    Private hBitmap As IntPtr
    Private program_file_path As String
    Private filedirectory As String
    Private filename As String
    Private output_message As String

    Private traditional_or_xml_format As Int32

    Private ofd As OpenFileDialog = New OpenFileDialog
    Private fInfo As IO.FileInfo
    Private utf8 As New UTF8Encoding
    Private encoding = New System.Text.ASCIIEncoding
    Private image_compression_code As String
    Private ptr_image_compression_code As IntPtr



    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _RegisterNIST() As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _CreateNewNISTFile() As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _WriteNISTToFile(ByVal FileName As Byte()) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadNISTByteArray() As IntPtr
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadSizeOfNISTByteArray() As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadNISTFromFile(ByVal FileName As Byte()) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadNISTFromMemory(ByVal byte_array As Byte(), ByVal size_of_byte_array As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _CheckIfRecordTypeExists(ByVal record_type_number As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadNumberOfRecords(ByVal record_type_number As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadIDCofRecord(ByVal record_type_number As Int32, ByVal idc As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadRecordTxtField(ByVal record_type_number As Int32, ByVal idc As Int32, ByVal record_field_number As Int32, ByVal record_field_name As Byte()) As IntPtr
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadSizeOfRecordTxtField(ByVal record_type_number As Int32, ByVal idc As Int32, ByVal record_field_number As Int32, ByVal record_field_name As Byte()) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadRecordTxtFieldName(ByVal record_type_number As Int32, ByVal idc As Int32, ByVal record_field_number As Int32) As IntPtr
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadSizeOfRecordTxtFieldName(ByVal record_type_number As Int32, ByVal idc As Int32, ByVal record_field_number As Int32, ByVal record_field_name As Byte()) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadRecordTxtFieldDescription(ByVal record_type_number As Int32, ByVal idc As Int32, ByVal record_field_number As Int32, ByVal record_field_name As Byte()) As IntPtr
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadSizeOfRecordTxtFieldDescription(ByVal record_type_number As Int32, ByVal idc As Int32, ByVal record_field_number As Int32, ByVal record_field_name As Byte()) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadRecordExportedTxtFields(ByVal record_type_number As Int32, ByVal idc As Int32) As IntPtr
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadSizeOfRecordExportedTxtFields(ByVal record_type_number As Int32, ByVal idc As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadRecordBinaryField(ByVal record_type_number As Int32, ByVal idc As Int32) As IntPtr
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadSizeOfRecordBinaryField(ByVal record_type_number As Int32, ByVal idc As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _CreateHBITMAPfromRecordBinaryField(ByVal record_type_number As Int32, ByVal idc As Int32) As IntPtr
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _InsertRecordBinaryFieldFromFile(ByVal record_type_number As Int32, ByVal idc As Int32, ByVal FileName As Byte()) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _InsertRecordBinaryFieldFromMemory(ByVal record_type_number As Int32, ByVal idc As Int32, ByVal input_byte_array As Byte(), ByVal size_of_input_byte_array As Int32, ByVal CGA As Byte(), ByVal CGA_int As Int32, ByVal HLL As Int32, ByVal VLL As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _InsertRecordTxtField(ByVal record_type_number As Int32, ByVal idc As Int32, ByVal record_field_number As Int32, ByVal record_field_name As Byte(), ByVal input_data As Byte()) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _DeleteRecord(ByVal record_type_number As Int32, ByVal idc As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _SetNISTLibErrorReportMode(ByVal nist_error_report_mode As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _ReadNISTLibLastErrorMessage() As IntPtr
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _SetNISTLibTryToDecodeBinaryField(ByVal try_to_decode_binary_field As Int32) As Int32
    End Function

    <CLSCompliant(False), DllImport("NIST_library.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Ansi)> _
    Shared Function _SetAnsiNistItlVersion(ByVal version_year As Int32, ByVal traditional_or_xml As Int32) As Int32
    End Function





    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        hBitmap = IntPtr.Zero

        ofd.Filter = "All NIST files|*.nist;*.an2;*.eft;*.xml|NIST files (*.nist)|*.nist|AN2 files (*.an2)|*.an2|EFT files (*.eft)|*.eft|NIEM-conformant XML files (*.xml)|*.xml|All files (*.*)|*.*"
        ofd.FilterIndex = 1


        ' Gets full filename of the program
        Dim mainAssembly As [Assembly] = [Assembly].GetExecutingAssembly()
        ' Set output directory
        program_file_path = Path.GetDirectoryName(mainAssembly.Location)

        traditional_or_xml_format = 0 ' traditional format

    End Sub



    Private Sub RegisterButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegisterButton.Click

        _RegisterNIST()

    End Sub


    Private Sub CreateAndInsertButton_Click(sender As Object, e As EventArgs) Handles CreateAndInsertButton.Click

        CreateAndInsertButton.Enabled = False
        ReadAndModifyButton.Enabled = False
        ReadAndExportButton.Enabled = False
        ReadSingleFieldButton.Enabled = False
        DeleteSingleFieldButton.Enabled = False
        RegisterButton.Enabled = False
        Cursor.Current = Cursors.WaitCursor


        ' In function _SetAnsiNistItlVersion(int version_year, int traditional_or_xml)
        ' first argument denotes version year of ANSI/NIST-ITL standard, possible values: 1986, 1993, 1997, 2000, 2007, 2009, 2011, 2013, 2015
        ' second argument denotes nist file format. 0 denotes traditional format, 1 denotes NIEM-conformant XML format.

        traditional_or_xml_format = 0 ' traditional format
        ' traditional_or_xml_format = 1 ' NIEM-conformant XML format
        _SetAnsiNistItlVersion(2000, traditional_or_xml_format) ' NIEM-conformant XML format

        ' Creates new empty NIST file
        _CreateNewNISTFile()


        ' ======================================================
        MessageBox.Show("Inserting/replacing Type-1 and Type-2 records...")

        ' Type-1 record Logical record length (LEN) field is handled automatically
        ' and the value of the utf8.GetBytes("LEN") field cannot be changed manually.
        ' InsertType1Record(utf8.GetBytes("LEN"), "100")

        ' You can modify value of Type-1 record Version number (VER) field, however please keep in mind that
        ' the entry in utf8.GetBytes("VER") field for ANSI/NIST-ITL 1-2000 approved standard must be "0300".
        ' InsertType1Record(utf8.GetBytes("VER"), "0300")

        ' Modifies NIST file, inserts/replaces Type-1 record Type of transaction (TOT)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("TOT"), utf8.GetBytes("IMG"))

        ' Modifies NIST file, inserts/replaces Type-1 record date (DAT)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("DAT"), utf8.GetBytes("20081031"))
        Else
            _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("DAT"), utf8.GetBytes("2008-10-31"))
        End If

        ' Modifies NIST file, inserts/replaces Type-1 record Priority (PRY)
        ' The length of Priority (PRY) field must be equal to 1 bytes
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("PRY"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces Type-1 record Destination agency identifier (DAI)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("DAI"), utf8.GetBytes("Central Police Station"))

        ' Modifies NIST file, inserts/replaces Type-1 record Originating agency identifier (ORI)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("ORI"), utf8.GetBytes("Local Police Station"))

        ' Modifies NIST file, inserts/replaces Type-1 record Transaction control number (TCN)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("TCN"), utf8.GetBytes("000045321"))

        ' Modifies NIST file, inserts/replaces Type-1 record Transaction control reference (TCR)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("TCR"), utf8.GetBytes("0000078901"))

        ' Modifies NIST file, inserts/replaces Type-1 record Native scanning resolution(NSR)
        ' The length of Native scanning resolution(NSR) field must be equal to 5 bytes
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("NSR"), utf8.GetBytes("19.69"))

        ' Modifies NIST file, inserts/replaces Type-1 record Nominal transmitting resolution (NTR)
        ' The length of Nominal transmitting resolution (NTR) field must be equal to 5 bytes
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("NTR"), utf8.GetBytes("19.69"))

        ' Modifies NIST file, inserts/replaces Type-1 record Domain name (DOM)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("DOM"), utf8.GetBytes("NORAM"))

        ' Modifies NIST file, inserts/replaces Type-1 record Greenwich mean time (GMT)
        ' The length of Greenwich mean time (GMT) field must be equal to 15 bytes
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("GMT"), utf8.GetBytes("20081031152345Z"))
        Else
            _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("GMT"), utf8.GetBytes("2008-09-31T17:03:16Z"))
        End If


        ' Modifies NIST file, inserts three Type-2 records,
        ' if these records already exist then they are overwritten and replaced

        ' Inserts first Type-2 record
        idc_current = _InsertRecordTxtField(2, -1, 30, utf8.GetBytes(""), utf8.GetBytes("James Clerk"))
        _InsertRecordTxtField(2, idc_current, 31, utf8.GetBytes(""), utf8.GetBytes("Maxwell"))
        _InsertRecordTxtField(2, idc_current, 32, utf8.GetBytes(""), utf8.GetBytes("Berlin, Germany"))

        ' Inserts second Type-2 record
        idc_current = _InsertRecordTxtField(2, -1, 30, utf8.GetBytes(""), utf8.GetBytes("John Smith"))
        _InsertRecordTxtField(2, idc_current, 31, utf8.GetBytes(""), utf8.GetBytes("Watson"))
        _InsertRecordTxtField(2, idc_current, 32, utf8.GetBytes(""), utf8.GetBytes("London, UK"))

        ' Inserts third Type-2 record
        idc_current = _InsertRecordTxtField(2, -1, 30, utf8.GetBytes(""), utf8.GetBytes("Alphonse Gabriel"))
        _InsertRecordTxtField(2, idc_current, 31, utf8.GetBytes(""), utf8.GetBytes("Al Capone"))
        _InsertRecordTxtField(2, idc_current, 32, utf8.GetBytes(""), utf8.GetBytes("New York, USA"))



        ' Sets input directory as "input" subdirectory of the program location
        filedirectory = program_file_path + "\input\"


        MessageBox.Show("Inserting/replacing Type-4 records...")

        ' Modifies NIST file, inserts 14 Type-4 records (inserts 14 fingerprint WSQ images).
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced

        filename = filedirectory + "type4_01.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("10"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))



        filename = filedirectory + "type4_02.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("9"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_03.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("8"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_04.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("7"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_05.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("6"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_06.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("5"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_07.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("4"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))



        filename = filedirectory + "type4_08.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("3"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_09.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("2"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_10.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("1"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_11.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("14"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_12.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("13"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_13.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("12"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_14.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, -1, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("11"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))   




        ' Fields of the Type-7 logical record are user-defined.
        ' Individual fields required for a given transaction, such as field description,
        ' size, and content shall conform to the specifications set forth by the agency
        ' to whom the transmission is being sent.
        ' "NIST library" uses Interpol Implementation of the Type-7 logical record,
        ' prepared by The Interpol AFIS Expert Group, version No. 4.22b – October 28, 2005
        MessageBox.Show("Inserting/replacing Type-7 records...")

        ' Modifies NIST file, inserts Type-7 records.    
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced

        filename = filedirectory + "type7_01.jpg"
        idc_current = _InsertRecordBinaryFieldFromFile(7, -1, utf8.GetBytes(filename))

        _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMT"), utf8.GetBytes("1"))
        _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMD"), utf8.GetBytes("25"))
        ' PCN value of "0000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("PCN"), "0000000000")
        ' IMR value of "00000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMR"), "00000000000")
        ' HLL value of image width was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' GCA value was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("3"))

        filename = filedirectory + "type7_02.jpg"
        idc_current = _InsertRecordBinaryFieldFromFile(7, -1, utf8.GetBytes(filename))

        _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMT"), utf8.GetBytes("1"))
        _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMD"), utf8.GetBytes("26"))
        ' PCN value of "0000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("PCN"), "0000000000")
        ' IMR value of "00000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMR"), "00000000000")
        ' HLL value of image width was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' GCA value was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("3"))

        filename = filedirectory + "type7_03.jpg"
        idc_current = _InsertRecordBinaryFieldFromFile(7, -1, utf8.GetBytes(filename))

        _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMT"), utf8.GetBytes("1"))
        _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMD"), utf8.GetBytes("21"))
        ' PCN value of "0000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("PCN"), "0000000000")
        ' IMR value of "00000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMR"), "00000000000")
        ' HLL value of image width was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' GCA value was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("3"))


        filename = filedirectory + "type7_04.jpg"
        idc_current = _InsertRecordBinaryFieldFromFile(7, -1, utf8.GetBytes(filename))

        _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMT"), utf8.GetBytes("1"))
        _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMD"), utf8.GetBytes("22"))
        ' PCN value of "0000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("PCN"), "0000000000")
        ' IMR value of "00000000000" was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("IMR"), "00000000000")
        ' HLL value of image width was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' GCA value was already inserted by default when creating Type-7 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(7, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("3"))



        MessageBox.Show("Inserting/replacing Type-8 records...")

        ' Modifies NIST file, inserts Type-8 records.    
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced

        filename = filedirectory + "type8_01.bin"
        idc_current = _InsertRecordBinaryFieldFromFile(8, -1, utf8.GetBytes(filename))

        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("SIG"), utf8.GetBytes("0"))
        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("SRT"), utf8.GetBytes("0"))
        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value (image width) needs to be set manually because input file is in uncompressed format, and cannot be determined automatically when creating Type-8 record
        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("1000"))
        ' VLL value (image height) needs to be set manually because input file is in uncompressed format, and cannot be determined automatically when creating Type-8 record
        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("500"))


        filename = filedirectory + "type8_02.bin"
        idc_current = _InsertRecordBinaryFieldFromFile(8, -1, utf8.GetBytes(filename))

        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("SIG"), utf8.GetBytes("1"))
        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("SRT"), utf8.GetBytes("0"))
        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value (image width) needs to be set manually because input file is in uncompressed format, and cannot be determined automatically when creating Type-8 record
        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("1000"))
        ' VLL value (image height) needs to be set manually because input file is in uncompressed format, and cannot be determined automatically when creating Type-8 record
        _InsertRecordTxtField(8, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("500"))




        MessageBox.Show("Inserting/replacing Type-10 records...")

        ' Modifies NIST file, inserts Type-10 records.
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced


        filename = filedirectory + "type10_01.jpg"
        ' filename = filedirectory + "type10_01.png"
        ' filename = filedirectory + "type10_01.jp2"   

        idc_current = _InsertRecordBinaryFieldFromFile(10, -1, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("IMT"), utf8.GetBytes("FACE"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("20091217"))
        Else
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("2009-12-17"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (THPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("300"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("300"))

        ' "NIST library" inserts CGA value "JPEGB" automatically when creating Type-10 record, based on filename *.jpg extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CGA"), "JPEGB")

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)   
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CSP"), utf8.GetBytes("RGB"))
        ' _InsertRecordTxtField(10, idc_current, 12, utf8.GetBytes(""), utf8.GetBytes("RGB"))

        ' Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("POS"), utf8.GetBytes("F"))   ' Full Face Frontal


        ' filename = filedirectory + "type10_02.jpg"
        filename = filedirectory + "type10_02.png"
        ' filename = filedirectory + "type10_02.jp2"

        idc_current = _InsertRecordBinaryFieldFromFile(10, -1, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("IMT"), utf8.GetBytes("FACE"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("20091217"))
        Else
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("2009-12-17"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (THPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("300"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("300"))

        ' "NIST library" inserts CGA value "PNG" automatically when creating Type-10 record, based on filename *.jp2 extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CGA"), "PNG")

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)   
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CSP"), utf8.GetBytes("RGB"))
        ' _InsertRecordTxtField(10, idc_current, 12, utf8.GetBytes(""), utf8.GetBytes("RGB"))

        ' Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("POS"), utf8.GetBytes("R"))   ' Right Profile


        ' filename = filedirectory + "type10_03.jpg"
        ' filename = filedirectory + "type10_03.png"
        filename = filedirectory + "type10_03.jp2"


        idc_current = _InsertRecordBinaryFieldFromFile(10, -1, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("IMT"), utf8.GetBytes("FACE"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("20091217"))
        Else
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("2009-12-17"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (THPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("300"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("300"))

        ' "NIST library" inserts CGA value "JP2" automatically when creating Type-10 record, based on filename *.jp2 extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CGA"), "JP2")

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)   
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CSP"), utf8.GetBytes("RGB"))
        ' _InsertRecordTxtField(10, idc_current, 12, utf8.GetBytes(""), utf8.GetBytes("RGB"))

        ' Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("POS"), utf8.GetBytes("A"))   ' Angled Pose



        MessageBox.Show("Inserting/replacing Type-13 records...")

        ' Modifies NIST file, inserts Type-13 records.
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced

        filename = filedirectory + "type13_01.wsq"

        idc_current = _InsertRecordBinaryFieldFromFile(13, -1, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-13 record Impression type (IMP)
        _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("6"))

        ' Modifies NIST file, inserts/replaces mandatory Type-13 record Source agency / ORI (SRC)
        _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("MDNISTVIP"))

        ' Modifies NIST file, inserts/replaces mandatory Type-13 record Latent capture date (LCD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("LCD"), utf8.GetBytes("19990707"))
        Else
            _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("LCD"), utf8.GetBytes("1999-07-07"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-13 record Scale units (SLC)
        _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("2"))

        ' Modifies NIST file, inserts/replaces mandatory Type-13 record Horizontal pixel scale (THPS)
        _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("197"))

        ' Modifies NIST file, inserts/replaces mandatory Type-13 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("197"))

        ' Modifies NIST file, inserts/replaces mandatory Type-13 record Compression algorithm (CGA)
        ' "NIST library" inserts CGA value "WSQ20" automatically when creating Type-13 record, based on filename *.wsq extension, here you can overwrite it with new value if needed   
        ' _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("CGA") , "WSQ20")

        ' Modifies NIST file, inserts/replaces mandatory Type-13 record Bits per pixel (BPX)
        _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("BPX"), utf8.GetBytes("8"))

        ' Modifies NIST file, inserts/replaces mandatory Type-13 record Finger / palm position (FGP)
        _InsertRecordTxtField(13, idc_current, -1, utf8.GetBytes("FGP"), utf8.GetBytes("8"))



        MessageBox.Show("Inserting/replacing Type-14 records...")

        ' Modifies NIST file, inserts Type-14 records.
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced

        filename = filedirectory + "type14_01.wsq"

        idc_current = _InsertRecordBinaryFieldFromFile(14, -1, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Impression type (IMP)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Source agency / ORI (SRC)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("MDNISTVIP"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Tenprint capture date (TCD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("TCD"), utf8.GetBytes("19990707"))
        Else
            _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("TCD"), utf8.GetBytes("1999-07-07"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Scale units (SLC)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("2"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Horizontal pixel scale (THPS)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("197"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("197"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Compression algorithm (CGA)
        ' "NIST library" inserts CGA value "WSQ20" automatically when creating Type-14 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("CGA") , "WSQ20")

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Bits per pixel (BPX)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("BPX"), utf8.GetBytes("8"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Finger position (FGP)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("FGP"), utf8.GetBytes("8"))



        MessageBox.Show("Inserting/replacing Type-15 records...")

        ' Modifies NIST file, inserts Type-15 records.
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced   


        filename = filedirectory + "type15_01.wsq"

        idc_current = _InsertRecordBinaryFieldFromFile(15, -1, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Impression type (IMP)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("10"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Source agency/ORI (SRC)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint capture date (PCD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("PCD"), utf8.GetBytes("20091217"))
        Else
            _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("PCD"), utf8.GetBytes("2009-12-17"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Scale units (SLC)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Horizontal pixel scale (THPS)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("500"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("500"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Compression algorithm (CGA)
        ' "NIST library" inserts CGA value "WSQ20" automatically when creating Type-15 record, based on filename *.wsq extension, here you overwrite it with new value utf8.GetBytes("WSQ")
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("CGA"), utf8.GetBytes("WSQ"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Bits per pixel (BPX)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("BPX"), utf8.GetBytes("8"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint position (PLP)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("PLP"), utf8.GetBytes("24"))



        filename = filedirectory + "type15_02.wsq"

        idc_current = _InsertRecordBinaryFieldFromFile(15, -1, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Impression type (IMP)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("10"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Source agency/ORI (SRC)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint capture date (PCD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("PCD"), utf8.GetBytes("20091217"))
        Else
            _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("PCD"), utf8.GetBytes("2009-12-17"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Scale units (SLC)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Horizontal pixel scale (THPS)   
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("500"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("500"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Compression algorithm (CGA)
        ' "NIST library" inserts CGA value "WSQ20" automatically when creating Type-15 record, based on filename *.wsq extension, here you overwrite it with new value utf8.GetBytes("WSQ")   
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("CGA"), utf8.GetBytes("WSQ"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Bits per pixel (BPX)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("BPX"), utf8.GetBytes("8"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint position (PLP)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("PLP"), utf8.GetBytes("25"))


        filename = filedirectory + "type15_03.wsq"

        idc_current = _InsertRecordBinaryFieldFromFile(15, -1, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Impression type (IMP)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("10"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Source agency/ORI (SRC)   
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint capture date (PCD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("PCD"), utf8.GetBytes("20091217"))
        Else
            _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("PCD"), utf8.GetBytes("2009-12-17"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Scale units (SLC)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Horizontal pixel scale (THPS)   
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("500"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("500"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Compression algorithm (CGA)
        ' "NIST library" inserts CGA value "WSQ20" automatically when creating Type-15 record, based on filename *.wsq extension, here you overwrite it with new value utf8.GetBytes("WSQ")   
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("CGA"), utf8.GetBytes("WSQ"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Bits per pixel (BPX)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("BPX"), utf8.GetBytes("8"))

        ' Modifies NIST file, inserts/replaces mandatory Type-15 record Palmprint position (PLP)
        _InsertRecordTxtField(15, idc_current, -1, utf8.GetBytes("PLP"), utf8.GetBytes("27"))



        MessageBox.Show("Inserting/replacing Type-16 records...")

        ' Modifies NIST file, inserts Type-16 records.
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced

        filename = filedirectory + "type16_01.wsq"

        idc_current = _InsertRecordBinaryFieldFromFile(16, -1, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-16 record
        _InsertRecordTxtField(16, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-16 record
        _InsertRecordTxtField(16, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces mandatory Type-16 record
        _InsertRecordTxtField(16, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("500"))

        ' Modifies NIST file, inserts/replaces mandatory Type-16 record
        _InsertRecordTxtField(16, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("500"))

        ' Modifies NIST file, inserts/replaces mandatory Type-16 record
        ' "NIST library" inserts CGA value "WSQ20" automatically when creating Type-16 record, based on filename *.wsq extension, here you overwrite it with new value utf8.GetBytes("WSQ")   
        _InsertRecordTxtField(16, idc_current, -1, utf8.GetBytes("CGA"), utf8.GetBytes("WSQ"))

        ' Modifies NIST file, inserts/replaces mandatory Type-16 record
        _InsertRecordTxtField(16, idc_current, -1, utf8.GetBytes("BPX"), utf8.GetBytes("8"))

        ' Modifies NIST file, inserts/replaces Type-16 record
        _InsertRecordTxtField(16, idc_current, -1, utf8.GetBytes("CSP"), utf8.GetBytes("A01"))

        ' ======================================================



        ' Sets output file name as "sample_new.nist" (in "output" subdirectory)
        filedirectory = program_file_path + "\output\"
        If Not Directory.Exists(filedirectory) Then
            ' Create output directory
            Directory.CreateDirectory(filedirectory)
        End If

        If (traditional_or_xml_format = 0) Then
            filename = filedirectory + "sample_new.nist"
        Else
            filename = filedirectory + "sample_new.xml"
        End If


        ' Saves NIST into the file "sample_new.nist" (in "output" subdirectory)
        _WriteNISTToFile(utf8.GetBytes(filename))


        ' Instead function _WriteNISTToFile you can use function _ReadNISTByteArray and save NIST byte array manually (the code bellow)
        ' ==========================
        ' byte_array_ptr = _ReadNISTByteArray()
        ' size_of_byte_array = _ReadSizeOfNISTByteArray()

        ' ReDim byte_array(size_of_byte_array)
        ' Marshal.Copy(byte_array_ptr, byte_array, 0, size_of_byte_array)

        ' Dim fStream As IO.FileStream = New IO.FileStream(filename, IO.FileMode.Create)
        ' Dim bw As IO.BinaryWriter = New IO.BinaryWriter(fStream)

        ' bw.Write(byte_array)
        ' bw.Close()
        ' fStream.Close()
        ' ==========================

        If (traditional_or_xml_format = 0) Then
            MessageBox.Show("New NIST file was created, modified and saved as " & vbCrLf & Chr(34) & ".\output\sample_new.nist" & Chr(34) & "" & vbCrLf & vbCrLf & "Please use " & Chr(34) & "NIST viewer" & Chr(34) & " to see changes in" & vbCrLf & "" & Chr(34) & "sample_new.nist" & Chr(34) & " file.")
        Else
            MessageBox.Show("New NIST file was created, modified and saved as " & vbCrLf & Chr(34) & ".\output\sample_new.xml" & Chr(34) & "" & vbCrLf & vbCrLf & "Please use " & Chr(34) & "NIST viewer" & Chr(34) & " to see changes in" & vbCrLf & "" & Chr(34) & "sample_new.xml" & Chr(34) & " file.")
        End If


        CreateAndInsertButton.Enabled = True
        ReadAndModifyButton.Enabled = True
        ReadAndExportButton.Enabled = True
        ReadSingleFieldButton.Enabled = True
        DeleteSingleFieldButton.Enabled = True
        RegisterButton.Enabled = True
        Cursor.Current = Cursors.Default

    End Sub



    Private Sub ReadAndExportButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReadAndExportButton.Click


        ofd.FilterIndex = 1


        ' Display the Open dialog box.
        If Not ofd.ShowDialog() = DialogResult.OK Then
            Exit Sub
        End If


        CreateAndInsertButton.Enabled = False
        ReadAndModifyButton.Enabled = False
        ReadAndExportButton.Enabled = False
        ReadSingleFieldButton.Enabled = False
        DeleteSingleFieldButton.Enabled = False
        RegisterButton.Enabled = False
        Cursor.Current = Cursors.WaitCursor


        ' Set output directory
        filedirectory = program_file_path + "\output\"


        If Not Directory.Exists(filedirectory) Then
            ' Create output directory
            Directory.CreateDirectory(filedirectory)
        End If



        ' Reads NIST file, loads NIST file contents into memory and decodes NIST file data into
        ' usable format. This function must be called at the beginning (one time only) before
        ' any further processing of NIST file.
        ' _ReadNISTFromFile(ofd.FileName)

        ' Instead function ReadNISTFile you can use function _ReadNISTFromMemory (the code bellow)
        ' ==========================

        fInfo = New IO.FileInfo(ofd.FileName)
        size_of_byte_array = fInfo.Length
        fStream = New IO.FileStream(ofd.FileName, IO.FileMode.Open, IO.FileAccess.Read)
        br = New IO.BinaryReader(fStream)
        byte_array = br.ReadBytes(size_of_byte_array)
        br.Close()
        fStream.Close()

        ' Loads NIST file contents from memory and decodes NIST file data into
        ' usable format. This function must be called at the beginning (one time only) before
        ' any further processing of NIST file.     
        _ReadNISTFromMemory(byte_array, size_of_byte_array)
        ' ==========================


        If (_CheckIfRecordTypeExists(1) = 1) Then

            ' Returns size_of_byte_array of text NIST field.
            size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(1, 0)
            ' Returns contents of NIST file data field as text string (char array).     
            ptr_nist_txt_field = _ReadRecordExportedTxtFields(1, 0)
            nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

            ' Sets filename for saving exported data of text field from type 1 record
            filename = filedirectory + "type1.txt"
            If (File.Exists(filename)) Then
                File.Delete(filename)
            End If
            fStream = New FileStream(filename, FileMode.CreateNew)
            bw = New BinaryWriter(fStream)
            ' Writes exported data of text field from type 1 record to the file
            bw.Write(encoding.GetBytes(nist_txt_field))
            bw.Close()
            fStream.Close()
            MessageBox.Show("Type-1 record text field was exported to file .\output\type1.txt")

        End If ' If (_CheckIfRecordTypeExists(1) = 1)


        If (_CheckIfRecordTypeExists(2) = 1) Then

            type_2_number_of_records = _ReadNumberOfRecords(2)

            For i As Int32 = 1 To type_2_number_of_records
                idc = _ReadIDCofRecord(2, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(2, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(2, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 2 record
                    filename = filedirectory + "type2_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 2 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                    MessageBox.Show("Type-2 record text field was exported to file .\output\type2_" + idc.ToString() + ".txt")
                End If



            Next i

        End If ' If (_CheckIfRecordTypeExists(2) = 1)


        If (_CheckIfRecordTypeExists(4) = 1) Then

            type_4_number_of_records = _ReadNumberOfRecords(4)

            ' In type 4 record there might be up to 14 fingerprint images.
            ' Reads NIST file and exports all images to separate files.
            For i As Int32 = 1 To type_4_number_of_records
                idc = _ReadIDCofRecord(4, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(4, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(4, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 4 record
                    filename = filedirectory + "type4_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 4 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                End If


                ' Returns size_of_byte_array of binary NIST field.
                size_of_byte_array = _ReadSizeOfRecordBinaryField(4, idc)

                If Not size_of_byte_array = 0 Then
                    ' Returns contents of NIST file binary field as byte array if successful,
                    ' returns NULL otherwise.
                    nist_binary_field = _ReadRecordBinaryField(4, idc)

                    ReDim byte_array([size_of_byte_array])
                    Marshal.Copy(nist_binary_field, byte_array, 0, size_of_byte_array)

                    ' Sets filename for saving exported data of text field from type 4 record
                    ptr_image_compression_code = _ReadRecordTxtField(4, idc, -1, utf8.GetBytes("GCA"))
                    image_compression_code = Marshal.PtrToStringAnsi(ptr_image_compression_code)

                    filename = filedirectory + "type4_" + idc.ToString()
                    output_message = "Type-4 record text field was exported to file .\output\type4_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-4 record binary field was exported to file .\output\type4_" + idc.ToString()

                    If ((image_compression_code = "0") Or (image_compression_code = "NONE")) Then
                        filename = filename + ".bin"
                        output_message = output_message + ".bin."
                    ElseIf ((image_compression_code = "1") Or (image_compression_code = "WSQ20") Or (image_compression_code = "WSQ")) Then
                        filename = filename + ".wsq"
                        output_message = output_message + ".wsq."
                    ElseIf ((image_compression_code = "2") Or (image_compression_code = "JPEGB") Or (image_compression_code = "3") Or (image_compression_code = "JPEGL")) Then
                        filename = filename + ".jpg"
                        output_message = output_message + ".jpg."
                    ElseIf ((image_compression_code = "4") Or (image_compression_code = "JP2") Or (image_compression_code = "5") Or (image_compression_code = "JP2L")) Then
                        filename = filename + ".jp2"
                        output_message = output_message + ".jp2."
                    ElseIf ((image_compression_code = "6") Or (image_compression_code = "PNG")) Then
                        filename = filename + ".png"
                        output_message = output_message + ".png."
                    End If

                    output_message = output_message & vbCrLf & vbCrLf & "High-resolution grayscale fingerprint image was extracted from Type-4 record" & vbCrLf & "binary field of NIST file and converted into HBITMAP for showing on form."

                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of binary field from type 4 record to the file
                    bw.Write(byte_array)
                    bw.Close()
                    fStream.Close()

                    ' Converts NIST file binary field contents into HBITMAP image.
                    ' Returns image in HBITMAP format if successful, returns NULL otherwise.

                    hBitmap = _CreateHBITMAPfromRecordBinaryField(4, idc)

                    If Not hBitmap.Equals(IntPtr.Zero) Then
                        OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                        Invalidate()
                        MessageBox.Show(output_message)
                    End If ' if ( hBitmap )
                End If ' If Not size_of_byte_array = 0 Then
            Next i

        End If ' If (_CheckIfRecordTypeExists(4) = 1)




        If (_CheckIfRecordTypeExists(7) = 1) Then

            type_7_number_of_records = _ReadNumberOfRecords(7)

            ' Reads NIST file and exports all images to separate files.
            For i As Int32 = 1 To type_7_number_of_records
                idc = _ReadIDCofRecord(7, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(7, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(7, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 7 record
                    filename = filedirectory + "type7_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 7 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                End If


                ' Returns size_of_byte_array of binary NIST field.
                size_of_byte_array = _ReadSizeOfRecordBinaryField(7, idc)

                If Not size_of_byte_array = 0 Then
                    ' Returns contents of NIST file binary field as byte array if successful,
                    ' returns NULL otherwise.
                    nist_binary_field = _ReadRecordBinaryField(7, idc)

                    ReDim byte_array([size_of_byte_array])
                    Marshal.Copy(nist_binary_field, byte_array, 0, size_of_byte_array)

                    ' Sets filename for saving exported data of text field from type 7 record
                    ptr_image_compression_code = _ReadRecordTxtField(7, idc, -1, utf8.GetBytes("GCA"))
                    image_compression_code = Marshal.PtrToStringAnsi(ptr_image_compression_code)

                    filename = filedirectory + "type7_" + idc.ToString()
                    output_message = "Type-7 record text field was exported to file .\output\type7_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-7 record binary field was exported to file .\output\type7_" + idc.ToString()

                    If ((image_compression_code = "0") Or (image_compression_code = "NONE")) Then
                        filename = filename + ".bin"
                        output_message = output_message + ".bin."
                    ElseIf ((image_compression_code = "1") Or (image_compression_code = "WSQ20") Or (image_compression_code = "WSQ")) Then
                        filename = filename + ".wsq"
                        output_message = output_message + ".wsq."
                    ElseIf ((image_compression_code = "2") Or (image_compression_code = "JPEGB") Or (image_compression_code = "3") Or (image_compression_code = "JPEGL")) Then
                        filename = filename + ".jpg"
                        output_message = output_message + ".jpg."
                    ElseIf ((image_compression_code = "4") Or (image_compression_code = "JP2") Or (image_compression_code = "5") Or (image_compression_code = "JP2L")) Then
                        filename = filename + ".jp2"
                        output_message = output_message + ".jp2."
                    ElseIf ((image_compression_code = "6") Or (image_compression_code = "PNG")) Then
                        filename = filename + ".png"
                        output_message = output_message + ".png."
                    End If

                    output_message = output_message & vbCrLf & vbCrLf & "User-defined image was extracted from Type-7 record" & vbCrLf & "binary field of NIST file and converted into HBITMAP for showing on form."

                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of binary field from type 7 record to the file
                    bw.Write(byte_array)
                    bw.Close()
                    fStream.Close()

                    ' Converts NIST file binary field contents into HBITMAP image.
                    ' Returns image in HBITMAP format if successful, returns NULL otherwise.

                    hBitmap = _CreateHBITMAPfromRecordBinaryField(7, idc)

                    If Not hBitmap.Equals(IntPtr.Zero) Then
                        OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                        Invalidate()
                        MessageBox.Show(output_message)
                    End If ' if ( hBitmap )
                End If ' If Not size_of_byte_array = 0 Then
            Next i

        End If ' If (_CheckIfRecordTypeExists(7) = 1)



        If (_CheckIfRecordTypeExists(8) = 1) Then

            type_8_number_of_records = _ReadNumberOfRecords(8)

            ' Reads NIST file and exports all images to separate files.
            For i As Int32 = 1 To type_8_number_of_records
                idc = _ReadIDCofRecord(8, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(8, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(8, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 8 record
                    filename = filedirectory + "type8_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 8 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                End If


                ' Returns size_of_byte_array of binary NIST field.
                size_of_byte_array = _ReadSizeOfRecordBinaryField(8, idc)

                If Not size_of_byte_array = 0 Then
                    ' Returns contents of NIST file binary field as byte array if successful,
                    ' returns NULL otherwise.
                    nist_binary_field = _ReadRecordBinaryField(8, idc)

                    ReDim byte_array([size_of_byte_array])
                    Marshal.Copy(nist_binary_field, byte_array, 0, size_of_byte_array)

                    ' Sets filename for saving exported data of text field from type 8 record
                    filename = filedirectory + "type8_" + idc.ToString() + ".bin"

                    ' Sets filename for saving exported data of text field from type 8 record
                    ' ptr_image_compression_code = _ReadRecordTxtField(8, idc, -1, utf8.GetBytes("GCA"))
                    ' image_compression_code = Marshal.PtrToStringAnsi(ptr_image_compression_code)

                    ' filename = filedirectory + "type8_" + idc.ToString()
                    output_message = "Type-8 record text field was exported to file .\output\type8_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-8 record binary field was exported to file .\output\type8_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-8 record binary field was exported to file .\output\type8_" + idc.ToString() + ".bin"

                    ' If ((image_compression_code = "0") Or (image_compression_code = "NONE")) Then
                    ' filename = filename + ".bin"
                    ' output_message = output_message + ".bin."
                    ' ElseIf ((image_compression_code = "1") Or (image_compression_code = "WSQ20") Or (image_compression_code = "WSQ")) Then
                    ' filename = filename + ".wsq"
                    ' output_message = output_message + ".wsq."
                    ' ElseIf ((image_compression_code = "2") Or (image_compression_code = "JPEGB") Or (image_compression_code = "3") Or (image_compression_code = "JPEGL")) Then
                    ' filename = filename + ".jpg"
                    ' output_message = output_message + ".jpg."
                    ' ElseIf ((image_compression_code = "4") Or (image_compression_code = "JP2") Or (image_compression_code = "5") Or (image_compression_code = "JP2L")) Then
                    ' filename = filename + ".jp2"
                    ' output_message = output_message + ".jp2."
                    ' ElseIf ((image_compression_code = "6") Or (image_compression_code = "PNG")) Then
                    ' filename = filename + ".png"
                    ' output_message = output_message + ".png."
                    ' End If

                    output_message = output_message & vbCrLf & vbCrLf & "Signature image was extracted from Type-8 record" & vbCrLf & "binary field of NIST file and converted into HBITMAP for showing on form."


                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of binary field from type 8 record to the file
                    bw.Write(byte_array)
                    bw.Close()
                    fStream.Close()

                    ' Converts NIST file binary field contents into HBITMAP image.
                    ' Returns image in HBITMAP format if successful, returns NULL otherwise.

                    hBitmap = _CreateHBITMAPfromRecordBinaryField(8, idc)

                    If Not hBitmap.Equals(IntPtr.Zero) Then
                        OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                        Invalidate()
                        MessageBox.Show(output_message)
                    End If ' if ( hBitmap )
                End If ' If Not size_of_byte_array = 0 Then
            Next i

        End If ' If (_CheckIfRecordTypeExists(8) = 1)



        If (_CheckIfRecordTypeExists(9) = 1) Then

            type_9_number_of_records = _ReadNumberOfRecords(9)

            ' Reads NIST file and exports all images to separate files.
            For i As Int32 = 1 To type_9_number_of_records
                idc = _ReadIDCofRecord(9, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(9, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(9, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 9 record
                    filename = filedirectory + "type9_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 9 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                End If


                ' Returns size_of_byte_array of binary NIST field.
                size_of_byte_array = _ReadSizeOfRecordBinaryField(9, idc)

                If Not size_of_byte_array = 0 Then
                    ' Returns contents of NIST file binary field as byte array if successful,
                    ' returns NULL otherwise.
                    nist_binary_field = _ReadRecordBinaryField(9, idc)

                    ReDim byte_array([size_of_byte_array])
                    Marshal.Copy(nist_binary_field, byte_array, 0, size_of_byte_array)

                    ' Sets filename for saving exported data of text field from type 9 record
                    filename = filedirectory + "type9_" + idc.ToString() + ".wsq"

                    ' Sets filename for saving exported data of text field from type 9 record
                    ' ptr_image_compression_code = _ReadRecordTxtField(9, idc, -1, utf8.GetBytes("GCA"))
                    ' image_compression_code = Marshal.PtrToStringAnsi(ptr_image_compression_code)

                    ' filename = filedirectory + "type9_" + idc.ToString()
                    output_message = "Type-9 record text field was exported to file .\output\type9_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-9 record binary field was exported to file .\output\type9_" + idc.ToString()

                    ' If ((image_compression_code = "0") Or (image_compression_code = "NONE")) Then
                    ' filename = filename + ".bin"
                    ' output_message = output_message + ".bin."
                    ' ElseIf ((image_compression_code = "1") Or (image_compression_code = "WSQ20") Or (image_compression_code = "WSQ")) Then
                    ' filename = filename + ".wsq"
                    ' output_message = output_message + ".wsq."
                    ' ElseIf ((image_compression_code = "2") Or (image_compression_code = "JPEGB") Or (image_compression_code = "3") Or (image_compression_code = "JPEGL")) Then
                    ' filename = filename + ".jpg"
                    ' output_message = output_message + ".jpg."
                    ' ElseIf ((image_compression_code = "4") Or (image_compression_code = "JP2") Or (image_compression_code = "5") Or (image_compression_code = "JP2L")) Then
                    ' filename = filename + ".jp2"
                    ' output_message = output_message + ".jp2."
                    ' ElseIf ((image_compression_code = "6") Or (image_compression_code = "PNG")) Then
                    ' filename = filename + ".png"
                    ' output_message = output_message + ".png."
                    ' End If

                    output_message = output_message & vbCrLf & vbCrLf & "Minutiae data was extracted from Type-9 record" & vbCrLf & "binary field of NIST file and converted into HBITMAP for showing on form."


                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of binary field from type 9 record to the file
                    bw.Write(byte_array)
                    bw.Close()
                    fStream.Close()

                    ' Converts NIST file binary field contents into HBITMAP image.
                    ' Returns image in HBITMAP format if successful, returns NULL otherwise.

                    hBitmap = _CreateHBITMAPfromRecordBinaryField(9, idc)

                    If Not hBitmap.Equals(IntPtr.Zero) Then
                        OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                        Invalidate()
                        MessageBox.Show(output_message)
                    End If ' if ( hBitmap )
                End If ' If Not size_of_byte_array = 0 Then
            Next i

        End If ' If (_CheckIfRecordTypeExists(9) = 1)



        If (_CheckIfRecordTypeExists(10) = 1) Then

            type_10_number_of_records = _ReadNumberOfRecords(10)

            ' Reads NIST file and exports all images to separate files.
            For i As Int32 = 1 To type_10_number_of_records
                idc = _ReadIDCofRecord(10, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(10, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(10, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 10 record
                    filename = filedirectory + "type10_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 10 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                End If


                ' Returns size_of_byte_array of binary NIST field.
                size_of_byte_array = _ReadSizeOfRecordBinaryField(10, idc)

                If Not size_of_byte_array = 0 Then
                    ' Returns contents of NIST file binary field as byte array if successful,
                    ' returns NULL otherwise.
                    nist_binary_field = _ReadRecordBinaryField(10, idc)

                    ReDim byte_array([size_of_byte_array])
                    Marshal.Copy(nist_binary_field, byte_array, 0, size_of_byte_array)

                    ' Sets filename for saving exported data of text field from type 10 record
                    ptr_image_compression_code = _ReadRecordTxtField(10, idc, -1, utf8.GetBytes("CGA"))
                    image_compression_code = Marshal.PtrToStringAnsi(ptr_image_compression_code)

                    filename = filedirectory + "type10_" + idc.ToString()
                    output_message = "Type-10 record text field was exported to file .\output\type10_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-10 record binary field was exported to file .\output\type10_" + idc.ToString()

                    If ((image_compression_code = "0") Or (image_compression_code = "NONE")) Then
                        filename = filename + ".bin"
                        output_message = output_message + ".bin."
                    ElseIf ((image_compression_code = "1") Or (image_compression_code = "WSQ20") Or (image_compression_code = "WSQ")) Then
                        filename = filename + ".wsq"
                        output_message = output_message + ".wsq."
                    ElseIf ((image_compression_code = "2") Or (image_compression_code = "JPEGB") Or (image_compression_code = "3") Or (image_compression_code = "JPEGL")) Then
                        filename = filename + ".jpg"
                        output_message = output_message + ".jpg."
                    ElseIf ((image_compression_code = "4") Or (image_compression_code = "JP2") Or (image_compression_code = "5") Or (image_compression_code = "JP2L")) Then
                        filename = filename + ".jp2"
                        output_message = output_message + ".jp2."
                    ElseIf ((image_compression_code = "6") Or (image_compression_code = "PNG")) Then
                        filename = filename + ".png"
                        output_message = output_message + ".png."
                    End If

                    output_message = output_message & vbCrLf & vbCrLf & "Facial & SMT image was extracted from Type-10 record" & vbCrLf & "binary field of NIST file and converted into HBITMAP for showing on form."

                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of binary field from type 10 record to the file
                    bw.Write(byte_array)
                    bw.Close()
                    fStream.Close()

                    ' Converts NIST file binary field contents into HBITMAP image.
                    ' Returns image in HBITMAP format if successful, returns NULL otherwise.

                    hBitmap = _CreateHBITMAPfromRecordBinaryField(10, idc)

                    If Not hBitmap.Equals(IntPtr.Zero) Then
                        OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                        Invalidate()
                        MessageBox.Show(output_message)
                    End If ' if ( hBitmap )
                End If ' If Not size_of_byte_array = 0 Then
            Next i

        End If ' If (_CheckIfRecordTypeExists(10) = 1)


        If (_CheckIfRecordTypeExists(13) = 1) Then

            type_13_number_of_records = _ReadNumberOfRecords(13)

            ' Reads NIST file and exports all images to separate files.
            For i As Int32 = 1 To type_13_number_of_records
                idc = _ReadIDCofRecord(13, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(13, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(13, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 13 record
                    filename = filedirectory + "type13_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 13 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                End If


                ' Returns size_of_byte_array of binary NIST field.
                size_of_byte_array = _ReadSizeOfRecordBinaryField(13, idc)

                If Not size_of_byte_array = 0 Then
                    ' Returns contents of NIST file binary field as byte array if successful,
                    ' returns NULL otherwise.
                    nist_binary_field = _ReadRecordBinaryField(13, idc)

                    ReDim byte_array([size_of_byte_array])
                    Marshal.Copy(nist_binary_field, byte_array, 0, size_of_byte_array)

                    ' Sets filename for saving exported data of text field from type 13 record
                    ptr_image_compression_code = _ReadRecordTxtField(13, idc, -1, utf8.GetBytes("CGA"))
                    image_compression_code = Marshal.PtrToStringAnsi(ptr_image_compression_code)

                    filename = filedirectory + "type13_" + idc.ToString()
                    output_message = "Type-13 record text field was exported to file .\output\type13_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-13 record binary field was exported to file .\output\type13_" + idc.ToString()

                    If ((image_compression_code = "0") Or (image_compression_code = "NONE")) Then
                        filename = filename + ".bin"
                        output_message = output_message + ".bin."
                    ElseIf ((image_compression_code = "1") Or (image_compression_code = "WSQ20") Or (image_compression_code = "WSQ")) Then
                        filename = filename + ".wsq"
                        output_message = output_message + ".wsq."
                    ElseIf ((image_compression_code = "2") Or (image_compression_code = "JPEGB") Or (image_compression_code = "3") Or (image_compression_code = "JPEGL")) Then
                        filename = filename + ".jpg"
                        output_message = output_message + ".jpg."
                    ElseIf ((image_compression_code = "4") Or (image_compression_code = "JP2") Or (image_compression_code = "5") Or (image_compression_code = "JP2L")) Then
                        filename = filename + ".jp2"
                        output_message = output_message + ".jp2."
                    ElseIf ((image_compression_code = "6") Or (image_compression_code = "PNG")) Then
                        filename = filename + ".png"
                        output_message = output_message + ".png."
                    End If

                    output_message = output_message & vbCrLf & vbCrLf & "Variable-resolution latent image was extracted from Type-13 record" & vbCrLf & "binary field of NIST file and converted into HBITMAP for showing on form."

                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of binary field from type 13 record to the file
                    bw.Write(byte_array)
                    bw.Close()
                    fStream.Close()

                    ' Converts NIST file binary field contents into HBITMAP image.
                    ' Returns image in HBITMAP format if successful, returns NULL otherwise.

                    hBitmap = _CreateHBITMAPfromRecordBinaryField(13, idc)

                    If Not hBitmap.Equals(IntPtr.Zero) Then
                        OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                        Invalidate()
                        MessageBox.Show(output_message)
                    End If ' if ( hBitmap )
                End If ' If Not size_of_byte_array = 0 Then
            Next i

        End If ' If (_CheckIfRecordTypeExists(13) = 1)


        If (_CheckIfRecordTypeExists(14) = 1) Then

            type_14_number_of_records = _ReadNumberOfRecords(14)

            ' Reads NIST file and exports all images to separate files.
            For i As Int32 = 1 To type_14_number_of_records
                idc = _ReadIDCofRecord(14, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(14, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(14, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 14 record
                    filename = filedirectory + "type14_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 14 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                End If


                ' Returns size_of_byte_array of binary NIST field.
                size_of_byte_array = _ReadSizeOfRecordBinaryField(14, idc)

                If Not size_of_byte_array = 0 Then
                    ' Returns contents of NIST file binary field as byte array if successful,
                    ' returns NULL otherwise.
                    nist_binary_field = _ReadRecordBinaryField(14, idc)

                    ReDim byte_array([size_of_byte_array])
                    Marshal.Copy(nist_binary_field, byte_array, 0, size_of_byte_array)

                    ' Sets filename for saving exported data of text field from type 14 record
                    ptr_image_compression_code = _ReadRecordTxtField(14, idc, -1, utf8.GetBytes("CGA"))
                    image_compression_code = Marshal.PtrToStringAnsi(ptr_image_compression_code)

                    filename = filedirectory + "type14_" + idc.ToString()
                    output_message = "Type-14 record text field was exported to file .\output\type14_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-14 record binary field was exported to file .\output\type14_" + idc.ToString()

                    If ((image_compression_code = "0") Or (image_compression_code = "NONE")) Then
                        filename = filename + ".bin"
                        output_message = output_message + ".bin."
                    ElseIf ((image_compression_code = "1") Or (image_compression_code = "WSQ20") Or (image_compression_code = "WSQ")) Then
                        filename = filename + ".wsq"
                        output_message = output_message + ".wsq."
                    ElseIf ((image_compression_code = "2") Or (image_compression_code = "JPEGB") Or (image_compression_code = "3") Or (image_compression_code = "JPEGL")) Then
                        filename = filename + ".jpg"
                        output_message = output_message + ".jpg."
                    ElseIf ((image_compression_code = "4") Or (image_compression_code = "JP2") Or (image_compression_code = "5") Or (image_compression_code = "JP2L")) Then
                        filename = filename + ".jp2"
                        output_message = output_message + ".jp2."
                    ElseIf ((image_compression_code = "6") Or (image_compression_code = "PNG")) Then
                        filename = filename + ".png"
                        output_message = output_message + ".png."
                    End If

                    output_message = output_message & vbCrLf & vbCrLf & "Variable-resolution fingerprint image was extracted from Type-14 record" & vbCrLf & "binary field of NIST file and converted into HBITMAP for showing on form."

                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of binary field from type 14 record to the file
                    bw.Write(byte_array)
                    bw.Close()
                    fStream.Close()

                    ' Converts NIST file binary field contents into HBITMAP image.
                    ' Returns image in HBITMAP format if successful, returns NULL otherwise.

                    hBitmap = _CreateHBITMAPfromRecordBinaryField(14, idc)

                    If Not hBitmap.Equals(IntPtr.Zero) Then
                        OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                        Invalidate()
                        MessageBox.Show(output_message)
                    End If ' if ( hBitmap )
                End If ' If Not size_of_byte_array = 0 Then
            Next i

        End If ' If (_CheckIfRecordTypeExists(14) = 1)


        If (_CheckIfRecordTypeExists(15) = 1) Then

            type_15_number_of_records = _ReadNumberOfRecords(15)

            ' Reads NIST file and exports all images to separate files.
            For i As Int32 = 1 To type_15_number_of_records
                idc = _ReadIDCofRecord(15, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(15, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(15, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 15 record
                    filename = filedirectory + "type15_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 15 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                End If


                ' Returns size_of_byte_array of binary NIST field.
                size_of_byte_array = _ReadSizeOfRecordBinaryField(15, idc)

                If Not size_of_byte_array = 0 Then
                    ' Returns contents of NIST file binary field as byte array if successful,
                    ' returns NULL otherwise.
                    nist_binary_field = _ReadRecordBinaryField(15, idc)

                    ReDim byte_array([size_of_byte_array])
                    Marshal.Copy(nist_binary_field, byte_array, 0, size_of_byte_array)

                    ' Sets filename for saving exported data of text field from type 15 record
                    ptr_image_compression_code = _ReadRecordTxtField(15, idc, -1, utf8.GetBytes("CGA"))
                    image_compression_code = Marshal.PtrToStringAnsi(ptr_image_compression_code)

                    filename = filedirectory + "type15_" + idc.ToString()
                    output_message = "Type-15 record text field was exported to file .\output\type15_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-15 record binary field was exported to file .\output\type15_" + idc.ToString()

                    If ((image_compression_code = "0") Or (image_compression_code = "NONE")) Then
                        filename = filename + ".bin"
                        output_message = output_message + ".bin."
                    ElseIf ((image_compression_code = "1") Or (image_compression_code = "WSQ20") Or (image_compression_code = "WSQ")) Then
                        filename = filename + ".wsq"
                        output_message = output_message + ".wsq."
                    ElseIf ((image_compression_code = "2") Or (image_compression_code = "JPEGB") Or (image_compression_code = "3") Or (image_compression_code = "JPEGL")) Then
                        filename = filename + ".jpg"
                        output_message = output_message + ".jpg."
                    ElseIf ((image_compression_code = "4") Or (image_compression_code = "JP2") Or (image_compression_code = "5") Or (image_compression_code = "JP2L")) Then
                        filename = filename + ".jp2"
                        output_message = output_message + ".jp2."
                    ElseIf ((image_compression_code = "6") Or (image_compression_code = "PNG")) Then
                        filename = filename + ".png"
                        output_message = output_message + ".png."
                    End If

                    output_message = output_message & vbCrLf & vbCrLf & "Variable-resolution palmprint image was extracted from Type-15 record" & vbCrLf & "binary field of NIST file and converted into HBITMAP for showing on form."

                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of binary field from type 15 record to the file
                    bw.Write(byte_array)
                    bw.Close()
                    fStream.Close()

                    ' Converts NIST file binary field contents into HBITMAP image.
                    ' Returns image in HBITMAP format if successful, returns NULL otherwise.

                    hBitmap = _CreateHBITMAPfromRecordBinaryField(15, idc)

                    If Not hBitmap.Equals(IntPtr.Zero) Then
                        OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                        Invalidate()
                        MessageBox.Show(output_message)
                    End If ' if ( hBitmap )
                End If ' If Not size_of_byte_array = 0 Then
            Next i

        End If ' If (_CheckIfRecordTypeExists(15) = 1)


        If (_CheckIfRecordTypeExists(16) = 1) Then

            type_16_number_of_records = _ReadNumberOfRecords(16)

            ' Reads NIST file and exports all images to separate files.
            For i As Int32 = 1 To type_16_number_of_records
                idc = _ReadIDCofRecord(16, i)

                ' Returns size_of_byte_array of text NIST field.
                size_of_byte_array = _ReadSizeOfRecordExportedTxtFields(16, idc)
                ' Returns contents of NIST file data field as text string (char array).     
                ptr_nist_txt_field = _ReadRecordExportedTxtFields(16, idc)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)

                If Not size_of_byte_array = 0 Then
                    ' Sets filename for saving exported data of text field from type 16 record
                    filename = filedirectory + "type16_" + idc.ToString() + ".txt"
                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of text field from type 16 record to the file
                    bw.Write(encoding.GetBytes(nist_txt_field))
                    bw.Close()
                    fStream.Close()
                End If


                ' Returns size_of_byte_array of binary NIST field.
                size_of_byte_array = _ReadSizeOfRecordBinaryField(16, idc)

                If Not size_of_byte_array = 0 Then
                    ' Returns contents of NIST file binary field as byte array if successful,
                    ' returns NULL otherwise.
                    nist_binary_field = _ReadRecordBinaryField(16, idc)

                    ReDim byte_array([size_of_byte_array])
                    Marshal.Copy(nist_binary_field, byte_array, 0, size_of_byte_array)

                    ' Sets filename for saving exported data of text field from type 16 record
                    ptr_image_compression_code = _ReadRecordTxtField(16, idc, -1, utf8.GetBytes("CGA"))
                    image_compression_code = Marshal.PtrToStringAnsi(ptr_image_compression_code)

                    filename = filedirectory + "type16_" + idc.ToString()
                    output_message = "Type-16 record text field was exported to file .\output\type16_" + idc.ToString() + ".txt." & vbCrLf & vbCrLf & "Type-16 record binary field was exported to file .\output\type16_" + idc.ToString()

                    If ((image_compression_code = "0") Or (image_compression_code = "NONE")) Then
                        filename = filename + ".bin"
                        output_message = output_message + ".bin."
                    ElseIf ((image_compression_code = "1") Or (image_compression_code = "WSQ20") Or (image_compression_code = "WSQ")) Then
                        filename = filename + ".wsq"
                        output_message = output_message + ".wsq."
                    ElseIf ((image_compression_code = "2") Or (image_compression_code = "JPEGB") Or (image_compression_code = "3") Or (image_compression_code = "JPEGL")) Then
                        filename = filename + ".jpg"
                        output_message = output_message + ".jpg."
                    ElseIf ((image_compression_code = "4") Or (image_compression_code = "JP2") Or (image_compression_code = "5") Or (image_compression_code = "JP2L")) Then
                        filename = filename + ".jp2"
                        output_message = output_message + ".jp2."
                    ElseIf ((image_compression_code = "6") Or (image_compression_code = "PNG")) Then
                        filename = filename + ".png"
                        output_message = output_message + ".png."
                    End If

                    output_message = output_message & vbCrLf & vbCrLf & "Variable-resolution user-defined testing image was extracted from Type-16 record" & vbCrLf & "binary field of NIST file and converted into HBITMAP for showing on form."

                    If (File.Exists(filename)) Then
                        File.Delete(filename)
                    End If
                    fStream = New FileStream(filename, FileMode.CreateNew)
                    bw = New BinaryWriter(fStream)
                    ' Writes exported data of binary field from type 16 record to the file
                    bw.Write(byte_array)
                    bw.Close()
                    fStream.Close()

                    ' Converts NIST file binary field contents into HBITMAP image.
                    ' Returns image in HBITMAP format if successful, returns NULL otherwise.

                    hBitmap = _CreateHBITMAPfromRecordBinaryField(16, idc)

                    If Not hBitmap.Equals(IntPtr.Zero) Then
                        OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                        Invalidate()
                        MessageBox.Show(output_message)
                    End If ' if ( hBitmap )
                End If ' If Not size_of_byte_array = 0 Then
            Next i

        End If ' If (_CheckIfRecordTypeExists(16) = 1)





        CreateAndInsertButton.Enabled = True
        ReadAndModifyButton.Enabled = True
        ReadAndExportButton.Enabled = True
        ReadSingleFieldButton.Enabled = True
        DeleteSingleFieldButton.Enabled = True
        RegisterButton.Enabled = True
        Cursor.Current = Cursors.Default

    End Sub

    Private Sub ReadSingleFieldButton_Click(sender As Object, e As EventArgs) Handles ReadSingleFieldButton.Click


        ofd.FilterIndex = 1

        ' Display the Open dialog box.
        If Not ofd.ShowDialog() = DialogResult.OK Then
            Exit Sub
        End If


        CreateAndInsertButton.Enabled = False
        ReadAndModifyButton.Enabled = False
        ReadAndExportButton.Enabled = False
        ReadSingleFieldButton.Enabled = False
        DeleteSingleFieldButton.Enabled = False
        RegisterButton.Enabled = False
        Cursor.Current = Cursors.WaitCursor



        ' Reads NIST file, loads NIST file contents into memory and decodes NIST file data into
        ' usable format. This function must be called at the beginning (one time only) before
        ' any further processing of NIST file.
        ' _ReadNISTFromFile(ofd.FileName)

        ' Instead function ReadNISTFile you can use function _ReadNISTFromMemory (the code bellow)
        ' ==========================

        fInfo = New IO.FileInfo(ofd.FileName)
        size_of_byte_array = fInfo.Length
        fStream = New IO.FileStream(ofd.FileName, IO.FileMode.Open, IO.FileAccess.Read)
        br = New IO.BinaryReader(fStream)
        byte_array = br.ReadBytes(size_of_byte_array)
        br.Close()
        fStream.Close()

        ' Loads NIST file contents from memory and decodes NIST file data into
        ' usable format. This function must be called at the beginning (one time only) before
        ' any further processing of NIST file.     
        _ReadNISTFromMemory(byte_array, size_of_byte_array)
        ' ==========================


        If ((Path.GetExtension(ofd.FileName)).ToLower() = ".xml") Then
            traditional_or_xml_format = 1 ' NIEM - conformant XML format
        Else
            traditional_or_xml_format = 0 ' traditional format
        End If


        If (_CheckIfRecordTypeExists(1) = 1) Then


            output_message = "Type-1 record field values were read in cycle using field number" & vbCrLf & vbCrLf



            For i As Int32 = 1 To 15
                output_message = output_message + "Type-1 record "
                ' Reads Type-1 record i Field Description
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtFieldDescription(1, -1, i, utf8.GetBytes("")))
                ' ptr_nist_txt_field = _ReadRecordTxtFieldDescription(1, -1, i, utf8.GetBytes(""))
                ' nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)
                output_message = output_message + nist_txt_field + " ("
                ' Reads Type-1 record i Field Name     
                ptr_nist_txt_field = _ReadRecordTxtFieldName(1, -1, i)
                nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)
                output_message = output_message + nist_txt_field + ") = "
                ' Reads Type-1 record i Field Value            
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, i, utf8.GetBytes("")))
                ' ptr_nist_txt_field = _ReadRecordTxtField(1, -1, i, utf8.GetBytes(""))
                ' nist_txt_field = Marshal.PtrToStringAnsi(ptr_nist_txt_field)
                output_message = output_message + nist_txt_field & vbCrLf
            Next i
            MessageBox.Show(output_message)

            ' Return

            output_message = "Type-1 record field values were read using field names" & vbCrLf & vbCrLf


            ' Reads Type-1 record Logical record length (LEN)
            If (traditional_or_xml_format = 0) Then
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("LEN")))
                output_message = output_message + "Type-1 record Logical record length (LEN) = "
                output_message = output_message + nist_txt_field
            End If

            ' Reads Type-1 record Version number (VER) of the standard implemented by the software or system creating the file
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("VER")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Version number (VER) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record File content (CNT)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("CNT")))
            output_message = output_message + "" & vbCrLf & "Type-1 record File content (CNT) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Type of transaction (TOT)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("TOT")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Type of transaction (TOT) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Date (DAT)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("DAT")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Date (DAT) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Priority _RY)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("PRY")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Priority (PRY) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Destination agency identifier (DAI)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("DAI")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Destination agency identifier (DAI) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Originating agency identifier (ORI)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("ORI")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Originating agency identifier (ORI) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Transaction control number (TCN)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("TCN")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Transaction control number (TCN) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Transaction control reference (TCR)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("TCR")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Transaction control reference (TCR) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Native scanning resolution(NSR)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("NSR")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Native scanning resolution (NSR) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Nominal transmitting resolution (NTR)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("NTR")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Nominal transmitting resolution (NTR) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Domain name (DOM)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("DOM")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Domain name (DOM) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Greenwich mean time (GMT)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("GMT")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Greenwich mean time (GMT) = "
            output_message = output_message + nist_txt_field

            ' Reads Type-1 record Directory of character sets (DCS)
            nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(1, -1, -1, utf8.GetBytes("DCS")))
            output_message = output_message + "" & vbCrLf & "Type-1 record Directory of character sets (DCS) = "
            output_message = output_message + nist_txt_field

            MessageBox.Show(output_message)

        End If ' If (_CheckIfRecordTypeExists(1) = 1) 


        If (_CheckIfRecordTypeExists(2) = 1) Then

            type_2_number_of_records = _ReadNumberOfRecords(2)
            output_message = "Type-2 number of records = " + type_2_number_of_records.ToString()

            MessageBox.Show(output_message)

            For i As Int32 = 1 To type_2_number_of_records
                ' Returns contents of NIST file data field as text string (char array).

                output_message = ""

                idc = _ReadIDCofRecord(2, i)

                ' Reads Type-2 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(2, idc, 1, utf8.GetBytes("")))
                    output_message = "Type-2 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                End If

                ' Reads Type-2 record Image designation character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(2, idc, 2, utf8.GetBytes("")))
                output_message = output_message + "" & vbCrLf & "Type-2 (" + idc.ToString() + ") record Image designation character (IDC) = " + nist_txt_field


                ' Reads Type-2 record User-defined field #30
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(2, idc, 30, utf8.GetBytes("")))
                output_message = output_message + "" & vbCrLf & "Type-2 (" + idc.ToString() + ") User-defined field #30 = " + nist_txt_field

                ' Reads Type-2 record User-defined field #31
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(2, idc, 31, utf8.GetBytes("")))
                output_message = output_message + "" & vbCrLf & "Type-2 (" + idc.ToString() + ") record User-defined field #31 = " + nist_txt_field


                ' Reads Type-2 record User-defined field #32
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(2, idc, 32, utf8.GetBytes("")))
                output_message = output_message + "" & vbCrLf & "Type-2 (" + idc.ToString() + ") record User-defined field #32 = " + nist_txt_field


                MessageBox.Show(output_message)
            Next i


        End If ' If (_CheckIfRecordTypeExists(2) = 1) 


        If (_CheckIfRecordTypeExists(4) = 1) Then

            type_4_number_of_records = _ReadNumberOfRecords(4)
            output_message = "Type-4 number of records = " + type_4_number_of_records.ToString()

            MessageBox.Show(output_message)


            ' In type 4 record there might be up to 14 fingerprint images.
            ' Reads NIST file and shows fingerprint images on the screen.
            For i As Int32 = 1 To type_4_number_of_records
                ' Returns contents of NIST file data field as text string (char array).

                output_message = ""

                idc = _ReadIDCofRecord(4, i)

                ' Reads Type-4 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("LEN")))
                    output_message = "Type-4 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                End If

                ' Reads Type-4 record Image designation character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("IDC")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Image designation character (IDC) = " + nist_txt_field

                ' Reads Type-4 record Impression type (IMP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("IMP")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Impression type (IMP) = " + nist_txt_field

                ' Reads Type-4 record Known or most probable Finger position (FGP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("FGP")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Known or most probable Finger position (FGP) = " + nist_txt_field

                ' Reads Type-4 record Known or most probable Finger position (FGP1)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("FGP1")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Known or most probable Finger position (FGP1) = " + nist_txt_field

                ' Reads Type-4 record Second possible Finger position (FGP2)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("FGP2")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Second possible Finger position (FGP2) = " + nist_txt_field

                ' Reads Type-4 record Third possible Finger position (FGP3)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("FGP3")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Third possible Finger position (FGP3) = " + nist_txt_field

                ' Reads Type-4 record Fourth possible Finger position (FGP4)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("FGP4")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Fourth possible Finger position (FGP4) = " + nist_txt_field

                ' Reads Type-4 record Fifth possible Finger position (FGP5)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("FGP5")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Fifth possible Finger position (FGP5) = " + nist_txt_field

                ' Reads Type-4 record Sixth possible Finger position (FGP6)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("FGP6")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Sixth possible Finger position (FGP6) = " + nist_txt_field

                ' Reads Type-4 record Image scanning resolution (ISR)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("ISR")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Image scanning resolution (ISR) = " + nist_txt_field

                ' Reads Type-4 record Horizontal line length (HLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("HLL")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Horizontal line length (HLL) = " + nist_txt_field

                ' Reads Type-4 record Vertical line length (VLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("VLL")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Vertical line length (VLL) = " + nist_txt_field

                ' Reads Type-4 record Grayscale compression algorithm (GCA)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(4, idc, -1, utf8.GetBytes("GCA")))
                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Grayscale compression algorithm (GCA) = " + nist_txt_field


                ' Returns Type-4 record Size of binary field.
                nist_int_field = _ReadSizeOfRecordBinaryField(4, idc)

                output_message = output_message + "" & vbCrLf & "Type-4 (" + idc.ToString() + ") record Size of binary field = " + nist_int_field.ToString()


                ' Returns contents of NIST file binary field as byte array if successful,
                ' returns NULL otherwise.
                ' nist_binary_field = _ReadType4RecordBinaryField(1, idc)


                ' Converts NIST file binary field contents into HBITMAP image.
                ' Returns image in HBITMAP format if successful, returns NULL otherwise.
                hBitmap = _CreateHBITMAPfromRecordBinaryField(4, idc)

                If Not hBitmap.Equals(IntPtr.Zero) Then
                    OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                    Invalidate()
                    output_message = output_message + "" & vbCrLf & "High-resolution grayscale fingerprint image was extracted from type 4 record binary field" & vbCrLf & "of NIST file and converted into HBITMAP for showing on form."
                    MessageBox.Show(output_message)
                End If ' if ( hBitmap )

            Next i


        End If ' If (_CheckIfRecordTypeExists(4) = 1) 


        If (_CheckIfRecordTypeExists(7) = 1) Then

            type_7_number_of_records = _ReadNumberOfRecords(7)
            output_message = "Type-7 number of records = " + type_7_number_of_records.ToString()

            MessageBox.Show(output_message)


            ' Reads NIST file and shows facial and SMT images on the screen.
            For i As Int32 = 1 To type_7_number_of_records

                output_message = ""

                idc = _ReadIDCofRecord(7, i)

                ' Reads Type-7 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(7, idc, -1, utf8.GetBytes("LEN")))
                    output_message = "Type-7 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                    output_message = output_message + nist_txt_field
                End If

                ' Reads Type-7 record Image designation character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(7, idc, -1, utf8.GetBytes("IDC")))
                output_message = output_message + "" & vbCrLf & "Type-7 (" + idc.ToString() + ") record Image designation character (IDC) = " + nist_txt_field

                ' Reads Type-7 record Image type (IMT)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(7, idc, -1, utf8.GetBytes("IMT")))
                output_message = output_message + "" & vbCrLf & "Type-7 (" + idc.ToString() + ") record Image type (IMT) = " + nist_txt_field

                ' Reads Type-7 record Image description (IMD)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(7, idc, -1, utf8.GetBytes("IMD")))
                output_message = output_message + "" & vbCrLf & "Type-7 (" + idc.ToString() + ") record Image description (IMD) = " + nist_txt_field

                ' Reads Type-7 record Pattern classification (PCN)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(7, idc, -1, utf8.GetBytes("PCN")))
                output_message = output_message + "" & vbCrLf & "Type-7 (" + idc.ToString() + ") record Pattern classification (PCN) = " + nist_txt_field

                ' Reads Type-7 record Image capture resolution (IMR)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(7, idc, -1, utf8.GetBytes("IMR")))
                output_message = output_message + "" & vbCrLf & "Type-7 (" + idc.ToString() + ") record Image capture resolution (IMR) = " + nist_txt_field

                ' Reads Type-7 record Horizontal line length (HLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(7, idc, -1, utf8.GetBytes("HLL")))
                output_message = output_message + "" & vbCrLf & "Type-7 (" + idc.ToString() + ") record Horizontal line length (HLL) = " + nist_txt_field

                ' Reads Type-7 record Horizontal line length (VLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(7, idc, -1, utf8.GetBytes("VLL")))
                output_message = output_message + "" & vbCrLf & "Type-7 (" + idc.ToString() + ") record Vertical line length (VLL) = " + nist_txt_field

                ' Reads Type-7 record Gray-scale compression algorithm (GCA)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(7, idc, -1, utf8.GetBytes("GCA")))
                output_message = output_message + "" & vbCrLf & "Type-7 (" + idc.ToString() + ") record Gray-scale compression algorithm (GCA) = " + nist_txt_field



                ' Converts NIST file binary field contents into HBITMAP image.
                ' Returns image in HBITMAP format if successful, returns NULL otherwise.
                hBitmap = _CreateHBITMAPfromRecordBinaryField(7, idc)

                If Not hBitmap.Equals(IntPtr.Zero) Then
                    OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                    Invalidate()
                    output_message = output_message + "" & vbCrLf & "User-defined image was extracted from type 7 record binary field" & vbCrLf & "of NIST file and converted into HBITMAP for showing on form."
                    MessageBox.Show(output_message)
                End If ' if ( hBitmap )                 


            Next i

        End If ' If (_CheckIfRecordTypeExists(7) = 1)


        If (_CheckIfRecordTypeExists(8) = 1) Then

            type_8_number_of_records = _ReadNumberOfRecords(8)
            output_message = "Type-8 number of records = " + type_8_number_of_records.ToString()

            MessageBox.Show(output_message)


            ' Reads NIST file and shows facial and SMT images on the screen.
            For i As Int32 = 1 To type_8_number_of_records

                output_message = ""

                idc = _ReadIDCofRecord(8, i)

                ' Reads Type-8 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(8, idc, -1, utf8.GetBytes("LEN")))
                    output_message = "Type-8 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                    output_message = output_message + nist_txt_field
                End If

                ' Reads Type-8 record Image designation character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(8, idc, -1, utf8.GetBytes("IDC")))
                output_message = output_message + "" & vbCrLf & "Type-8 (" + idc.ToString() + ") record Image designation character (IDC) = " + nist_txt_field

                ' Reads Type-8 record Signature type (SIG)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(8, idc, -1, utf8.GetBytes("SIG")))
                output_message = output_message + "" & vbCrLf & "Type-8 (" + idc.ToString() + ") record Signature type (SIG) = " + nist_txt_field

                ' Reads Type-8 record Signature representation type (SRT)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(8, idc, -1, utf8.GetBytes("SRT")))
                output_message = output_message + "" & vbCrLf & "Type-8 (" + idc.ToString() + ") record Signature representation type (SRT) = " + nist_txt_field

                ' Reads Type-8 record Image scanning resolution (ISR)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(8, idc, -1, utf8.GetBytes("ISR")))
                output_message = output_message + "" & vbCrLf & "Type-8 (" + idc.ToString() + ") record Image scanning resolution (ISR) = " + nist_txt_field

                ' Reads Type-8 record Horizontal line length (HLL)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(8, idc, -1, utf8.GetBytes("HLL")))
                output_message = output_message + "" & vbCrLf & "Type-8 (" + idc.ToString() + ") record Horizontal line length (HLL) = " + nist_txt_field

                ' Reads Type-8 record Vertical line length (VLL)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(8, idc, -1, utf8.GetBytes("VLL")))
                output_message = output_message + "" & vbCrLf & "Type-8 (" + idc.ToString() + ") record Vertical line length (VLL) = " + nist_txt_field



                ' Converts NIST file binary field contents into HBITMAP image.
                ' Returns image in HBITMAP format if successful, returns NULL otherwise.
                hBitmap = _CreateHBITMAPfromRecordBinaryField(8, idc)

                If Not hBitmap.Equals(IntPtr.Zero) Then
                    OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                    Invalidate()
                    output_message = output_message + "" & vbCrLf & "Signature image was extracted from type 8 record binary field" & vbCrLf & "of NIST file and converted into HBITMAP for showing on form."
                    MessageBox.Show(output_message)
                End If ' if ( hBitmap )                 


            Next i

        End If ' If (_CheckIfRecordTypeExists(8) = 1)


        If (_CheckIfRecordTypeExists(9) = 1) Then

            type_9_number_of_records = _ReadNumberOfRecords(9)
            output_message = "Type-9 number of records = " + type_9_number_of_records.ToString()

            MessageBox.Show(output_message)


            ' Reads NIST file and shows minutiae data images on the screen.
            For i As Int32 = 1 To type_9_number_of_records

                output_message = ""

                idc = _ReadIDCofRecord(9, i)

                ' Reads Type-9 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("LEN")))
                    output_message = "Type-9 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                    output_message = output_message + nist_txt_field
                End If

                ' Reads Type-9 record Image designation character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("IDC")))
                output_message = output_message + "" & vbCrLf & "Type-2 record Image designation character (IDC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-9 record Impression type (IMP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("IMP")))
                output_message = "Type-9 record Impression type (IMP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-9 record Minutiae format (FMT)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("FMT")))
                output_message = "Type-9 record Minutiae format (FMT) = "
                output_message = output_message + nist_txt_field

                If (nist_txt_field = "S") Then

                    ' Reads Type-9 record Originating fingerprint reading system (OFR)
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("OFR")))
                    output_message = "Type-9 record Originating fingerprint reading system (OFR) = "
                    output_message = output_message + nist_txt_field

                    ' Reads Type-9 record Finger position (FGP)
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("FGP")))
                    output_message = "Type-9 record Finger position (FGP) = "
                    output_message = output_message + nist_txt_field

                    ' Reads Type-9 record Fingerprint pattern classification (FPC)
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("FPC")))
                    output_message = "Type-9 record Fingerprint pattern classification (FPC) = "
                    output_message = output_message + nist_txt_field

                    ' Reads Type-9 record Core position (CRP)
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("CRP")))
                    output_message = "Type-9 record Core position (CRP) = "
                    output_message = output_message + nist_txt_field

                    ' Reads Type-9 record Delta(s) position (DLT)
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("DLT")))
                    output_message = "Type-9 record Delta(s) position (DLT) = "
                    output_message = output_message + nist_txt_field

                    ' Reads Type-9 record Number of minutiae (MIN)
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("MIN")))
                    output_message = "Type-9 record Number of minutiae (MIN) = "
                    output_message = output_message + nist_txt_field

                    ' Reads Type-9 record Number of minutiae (RDG)
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("RDG")))
                    output_message = "Type-9 record Minutiae ridge count indicator (RDG) = "
                    output_message = output_message + nist_txt_field

                    ' Reads Type-9 record Number of minutiae (MRC)
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(9, idc, -1, utf8.GetBytes("MRC")))
                    output_message = "Type-9 record Minutiae and ridge count data (MRC) = "
                    output_message = output_message + nist_txt_field

                End If ' If (nist_txt_field = "S") Then


                ' Converts NIST file binary field contents into HBITMAP image.
                ' Returns image in HBITMAP format if successful, returns NULL otherwise.
                hBitmap = _CreateHBITMAPfromRecordBinaryField(9, idc)

                If Not hBitmap.Equals(IntPtr.Zero) Then
                    OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                    Invalidate()
                    output_message = output_message + "" & vbCrLf & "Minutiae data was extracted from type 9 record binary field" & vbCrLf & "of NIST file and converted into HBITMAP for showing on form."
                    MessageBox.Show(output_message)
                End If ' if ( hBitmap )                

            Next i

        End If ' If (_CheckIfRecordTypeExists(9) = 1) 



        If (_CheckIfRecordTypeExists(10) = 1) Then

            type_10_number_of_records = _ReadNumberOfRecords(10)
            output_message = "Type-10 number of records = " + type_10_number_of_records.ToString()

            MessageBox.Show(output_message)


            ' Reads NIST file and shows facial and SMT images on the screen.
            For i As Int32 = 1 To type_10_number_of_records

                output_message = ""

                idc = _ReadIDCofRecord(10, i)

                ' Reads Type-10 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("LEN")))
                    output_message = "Type-10 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                    output_message = output_message + nist_txt_field
                End If

                ' Reads Type-10 record Image designation character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("IDC")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Image designation character (IDC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Image type (IMT)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("IMT")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Image type (IMT) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Source agency / ORI (SRC)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SRC")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Source agency / ORI (SRC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Photo date (PHD)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("PHD")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Photo date (PHD) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Horizontal line length (HLL)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("HLL")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Horizontal line length (HLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Vertical line length (VLL)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("VLL")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Vertical line length (VLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Scale units (SLC)      
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SLC")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Scale units (SLC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Horizontal pixel scale (THPS)      
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("THPS")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Horizontal pixel scale (THPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Vertical pixel scale (TVPS)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("TVPS")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Vertical pixel scale (TVPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Compression algorithm (CGA)          
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("CGA")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Compression algorithm (CGA) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Colorspace (CSP)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("CSP")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Colorspace (CSP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Subject acquisition profile (SAP)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SAP")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Subject acquisition profile (SAP) = "
                output_message = output_message + nist_txt_field


                ' Reads Type-10 record Subject pose (POS)      
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("POS")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Subject pose (POS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Pose offset angle (POA)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("POA")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Pose offset angle (POA) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Photo description (PXS)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("PXS")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Photo description (PXS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Photo acquisition source (PAS)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("PAS")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Photo acquisition source (PAS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Subject quality score (SQS)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SQS")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Subject quality score (SQS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Subject pose angles (SPA)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SPA")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Subject pose angles (SPA) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Subject facial description (SXS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SXS")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Subject facial description (SXS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Subject eye color (SEC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SEC")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Subject eye color (SEC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Subject hair color (SHC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SHC")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Subject hair color (SHC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Facial feature points (FFP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("FFP")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Facial feature points (FFP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Device monitoring mode (DMM)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("DMM")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Device monitoring mode (DMM) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record NCIC designation code (SMT)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SMT")))
                output_message = output_message + "" & vbCrLf & "Type-10 record NCIC designation code (SMT) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record SMT size (SMS)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SMS")))
                output_message = output_message + "" & vbCrLf & "Type-10 record SMT size (SMS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record SMT descriptors (SMD)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("SMD")))
                output_message = output_message + "" & vbCrLf & "Type-10 record SMT descriptors (SMD) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-10 record Color (COL)     
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(10, idc, -1, utf8.GetBytes("COL")))
                output_message = output_message + "" & vbCrLf & "Type-10 record Color (COL) = "
                output_message = output_message + nist_txt_field
                ' Application->MessageBox( output_message, "NIST library", MB_OK )


                ' Converts NIST file binary field contents into HBITMAP image.
                ' Returns image in HBITMAP format if successful, returns NULL otherwise.
                hBitmap = _CreateHBITMAPfromRecordBinaryField(10, idc)

                If Not hBitmap.Equals(IntPtr.Zero) Then
                    OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                    Invalidate()
                    output_message = output_message + "" & vbCrLf & "Facial & SMT image was extracted from type 10 record binary field" & vbCrLf & "of NIST file and converted into HBITMAP for showing on form."
                    MessageBox.Show(output_message)
                End If ' if ( hBitmap )                 


            Next i

        End If ' If (_CheckIfRecordTypeExists(10) = 1)



        If (_CheckIfRecordTypeExists(13) = 1) Then

            type_13_number_of_records = _ReadNumberOfRecords(13)
            output_message = "Type-13 number of records = " + type_13_number_of_records.ToString()

            MessageBox.Show(output_message)

            ' Reads NIST file and shows latent images on the screen.
            For i As Int32 = 1 To type_13_number_of_records

                output_message = ""

                idc = _ReadIDCofRecord(13, i)

                ' Reads Type-13 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("LEN")))
                    output_message = "Type-13 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                    output_message = output_message + nist_txt_field
                End If

                ' Reads Type-13 record Image Designation Character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("IDC")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Logical record length (IDC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Impression Type (IMP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("IMP")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Logical record length (IMP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Source agency / ORI (SRC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("SRC")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Source agency / ORI (SRC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Latent capture date (LCD)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("LCD")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Latent capture date (LCD) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Latent capture date (HLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("HLL")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Horizontal line length (HLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Latent capture date (VLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("VLL")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Vertical line length (VLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Scale units (SLC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("SLC")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Scale units (SLC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Horizontal pixel scale (THPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("THPS")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Horizontal pixel scale (THPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Vertical pixel scale (TVPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("TVPS")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Vertical pixel scale (TVPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Compression algorithm (CGA)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("CGA")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Compression algorithm (CGA) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Bits per pixel (BPX)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("BPX")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Bits per pixel (BPX) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Finger / palm position (FGP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("FGP")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Finger / palm position (FGP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Search position descriptors (SPD)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("SPD")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Search position descriptors (SPD) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Print position coordinates (PPC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("PPC")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Print position coordinates (PPC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Scanned horizontal pixel scale (SHPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("SHPS")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Scanned horizontal pixel scale (SHPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Scanned vertical pixel scale (SVPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("SVPS")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Scanned vertical pixel scale (SVPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-13 record Comment (COM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(13, idc, -1, utf8.GetBytes("COM")))
                output_message = output_message + "" & vbCrLf & "Type-13 record Comment (COM) = "
                output_message = output_message + nist_txt_field


                ' Converts NIST file binary field contents into HBITMAP image.
                ' Returns image in HBITMAP format if successful, returns NULL otherwise.
                hBitmap = _CreateHBITMAPfromRecordBinaryField(13, idc)

                If Not hBitmap.Equals(IntPtr.Zero) Then
                    OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                    Invalidate()
                    output_message = output_message + "" & vbCrLf & "Variable-resolution latent image was extracted from type 13 record binary field" & vbCrLf & "of NIST file and converted into HBITMAP for showing on form."
                    MessageBox.Show(output_message)
                End If ' if ( hBitmap ) 


            Next i

        End If ' If (_CheckIfRecordTypeExists(13) = 1)


        If (_CheckIfRecordTypeExists(14) = 1) Then

            type_14_number_of_records = _ReadNumberOfRecords(14)
            output_message = "Type-14 number of records = " + type_14_number_of_records.ToString()

            MessageBox.Show(output_message)

            ' Reads NIST file and shows tenprint images images on the screen.
            For i As Int32 = 1 To type_14_number_of_records

                output_message = ""

                idc = _ReadIDCofRecord(14, i)

                ' Reads Type-14 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("LEN")))
                    output_message = "Type-14 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                    output_message = output_message + nist_txt_field
                End If

                ' Reads Type-14 record Image designation character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("IDC")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Image designation character (IDC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Impression type (IMP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("IMP")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Impression type (IMP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Source agency / ORI (SRC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("SRC")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Source agency / ORI (SRC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Tenprint capture date (TCD)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("TCD")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Tenprint capture date (TCD) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Horizontal line length (HLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("HLL")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Horizontal line length (HLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Vertical line length (VLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("VLL")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Vertical line length (VLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Scale units (SLC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("SLC")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Scale units (SLC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Horizontal pixel scale (THPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("THPS")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Horizontal pixel scale (THPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Vertical pixel scale (TVPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("TVPS")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Vertical pixel scale (TVPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Compression algorithm (CGA)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("CGA")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Compression algorithm (CGA) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Bits per pixel (BPX)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("BPX")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Bits per pixel (BPX) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Finger position (FGP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("FGP")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Finger position (FGP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Print position descriptors (PPD)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("PPD")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Print position descriptors (PPD) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Print position coordinates (PPC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("PPC")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Print position coordinates (PPC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Scanned horizontal pixel scale (SHPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("SHPS")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Scanned horizontal pixel scale (SHPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Scanned vertical pixel scale (SVPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("SVPS")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Scanned vertical pixel scale (SVPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Amputated or bandaged (AMP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("AMP")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Amputated or bandaged (AMP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Comment (COM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("COM")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Comment (COM) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Finger segment position(s) (SEG)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("SEG")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Finger segment position(s) (SEG) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record NIST quality metric (NQM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("NQM")))
                output_message = output_message + "" & vbCrLf & "Type-14 record NIST quality metric (NQM) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Segmentation quality metric (SQM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("SQM")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Segmentation quality metric (SQM) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Fingerprint quality metric (FQM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("FQM")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Fingerprint quality metric (FQM) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Alternate finger segment position(s) (ASEG)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("ASEG")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Alternate finger segment position(s) (ASEG) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-14 record Device monitoring mode (DMM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(14, idc, -1, utf8.GetBytes("DMM")))
                output_message = output_message + "" & vbCrLf & "Type-14 record Device monitoring mode (DMM) = "
                output_message = output_message + nist_txt_field


                ' Converts NIST file binary field contents into HBITMAP image.
                ' Returns image in HBITMAP format if successful, returns NULL otherwise.
                hBitmap = _CreateHBITMAPfromRecordBinaryField(14, idc)

                If Not hBitmap.Equals(IntPtr.Zero) Then
                    OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                    Invalidate()
                    output_message = output_message + "" & vbCrLf & "Variable-resolution fingerprint image was extracted from type 14 record binary field" & vbCrLf & "of NIST file and converted into HBITMAP for showing on form."
                    MessageBox.Show(output_message)
                End If ' if ( hBitmap )                 


            Next i

        End If ' If (_CheckIfRecordTypeExists(14) = 1)



        If (_CheckIfRecordTypeExists(15) = 1) Then

            type_15_number_of_records = _ReadNumberOfRecords(15)
            output_message = "Type-15 number of records = " + type_15_number_of_records.ToString()

            MessageBox.Show(output_message)


            ' Reads NIST file and shows fingerprint images on the screen.
            For i As Int32 = 1 To type_15_number_of_records

                output_message = ""

                idc = _ReadIDCofRecord(15, i)

                ' Reads Type-15 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("LEN")))
                    output_message = "Type-15 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                    output_message = output_message + nist_txt_field
                End If

                ' Reads Type-15 record Image designation character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("IDC")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Image designation character (IDC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Impression type (IMP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("IMP")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Impression type (IMP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Source agency/ORI (SRC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("SRC")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Source agency/ORI (SRC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Palmprint capture date (PCD)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("PCD")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Palmprint capture date (PCD) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Horizontal line length (HLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("HLL")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Horizontal line length (HLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Vertical line length (VLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("VLL")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Vertical line length (VLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Scale units (SLC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("SLC")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Scale units (SLC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Horizontal pixel scale (THPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("THPS")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Horizontal pixel scale (THPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Vertical pixel scale (TVPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("TVPS")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Vertical pixel scale (TVPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Compression algorithm (CGA)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("CGA")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Compression algorithm (CGA) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Bits per pixel (BPX)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("BPX")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Bits per pixel (BPX) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Palmprint position (PLP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("PLP")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Palmprint position (PLP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Scanned horizontal pixel scale (SHPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("SHPS")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Scanned horizontal pixel scale (SHPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Scanned vertical pixel scale (SVPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("SVPS")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Scanned vertical pixel scale (SVPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Comment (COM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("COM")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Comment (COM) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Palmprint quality metric (PQM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("PQM")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Palmprint quality metric (PQM) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-15 record Device monitoring mode (DMM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(15, idc, -1, utf8.GetBytes("DMM")))
                output_message = output_message + "" & vbCrLf & "Type-15 record Device monitoring mode (DMM) = "
                output_message = output_message + nist_txt_field


                ' Converts NIST file binary field contents into HBITMAP image.
                ' Returns image in HBITMAP format if successful, returns NULL otherwise.
                hBitmap = _CreateHBITMAPfromRecordBinaryField(15, idc)

                If Not hBitmap.Equals(IntPtr.Zero) Then
                    OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                    Invalidate()
                    output_message = output_message + "" & vbCrLf & "Variable-resolution palmprint image was extracted from type 15 record binary field" & vbCrLf & "of NIST file and converted into HBITMAP for showing on form."
                    MessageBox.Show(output_message)
                End If ' if ( hBitmap )                                



            Next i

        End If ' If (_CheckIfRecordTypeExists(15) = 1) Then


        If (_CheckIfRecordTypeExists(16) = 1) Then

            type_16_number_of_records = _ReadNumberOfRecords(16)
            output_message = "Type-16 number of records = " + type_16_number_of_records.ToString()

            MessageBox.Show(output_message)


            ' Reads NIST file and shows fingerprint images on the screen.
            For i As Int32 = 1 To type_16_number_of_records

                output_message = ""

                idc = _ReadIDCofRecord(16, i)

                ' Reads Type-16 record Logical record length (LEN)
                If (traditional_or_xml_format = 0) Then
                    nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("LEN")))
                    output_message = "Type-16 (" + idc.ToString() + ") record Logical record length (LEN) = " + nist_txt_field
                    output_message = output_message + nist_txt_field
                End If

                ' Reads Type-16 record Image designation character (IDC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("IDC")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Image designation character (IDC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record User-Defined Image (UDI)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("UDI")))
                output_message = output_message + "" & vbCrLf & "Type-16 record User-Defined Image (UDI) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Source Agency / ORI (SRC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("SRC")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Source Agency / ORI (SRC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record User-Defined Testing Date (UTD)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("UTD")))
                output_message = output_message + "" & vbCrLf & "Type-16 record User-Defined Testing Date (UTD) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Horizontal Line Length (HLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("HLL")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Horizontal Line Length (HLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Vertical Line Length (VLL)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("VLL")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Vertical Line Length (VLL) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Scale Units (SLC)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("SLC")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Scale Units (SLC) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Horizontal Pixel Scale (THPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("THPS")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Horizontal Pixel Scale (THPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Vertical Pixel Scale (TVPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("TVPS")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Vertical Pixel Scale (TVPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Compression Algorithm (CGA)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("CGA")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Compression Algorithm (CGA) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Bits Per Pixel (BPX)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("BPX")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Bits Per Pixel (BPX) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Color Space (CSP)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("CSP")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Color Space (CSP) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Scanned Horizontal Pixel Scale (SHPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("SHPS")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Scanned Horizontal Pixel Scale (SHPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Scanned Vertical Pixel Scale (SVPS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("SVPS")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Scanned Vertical Pixel Scale (SVPS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Comment (COM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("COM")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Comment (COM) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record User-Defined Testing Image Quality Score (UQS)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("UQS")))
                output_message = output_message + "" & vbCrLf & "Type-16 record User-Defined Testing Image Quality Score (UQS) = "
                output_message = output_message + nist_txt_field

                ' Reads Type-16 record Device Monitoring Mode (DMM)
                nist_txt_field = Marshal.PtrToStringAnsi(_ReadRecordTxtField(16, idc, -1, utf8.GetBytes("DMM")))
                output_message = output_message + "" & vbCrLf & "Type-16 record Device Monitoring Mode (DMM) = "
                output_message = output_message + nist_txt_field


                ' Converts NIST file binary field contents into HBITMAP image.
                ' Returns image in HBITMAP format if successful, returns NULL otherwise.
                hBitmap = _CreateHBITMAPfromRecordBinaryField(16, idc)

                If Not hBitmap.Equals(IntPtr.Zero) Then
                    OutputPicture.Image = Bitmap.FromHbitmap(hBitmap)
                    Invalidate()
                    output_message = output_message + "" & vbCrLf & "Variable-resolution user-defined testing image was extracted from type 16 record binary field" & vbCrLf & "of NIST file and converted into HBITMAP for showing on form."
                    MessageBox.Show(output_message)
                End If ' if ( hBitmap )      





            Next i

        End If ' If (_CheckIfRecordTypeExists(16) = 1)


        CreateAndInsertButton.Enabled = True
        ReadAndModifyButton.Enabled = True
        ReadAndExportButton.Enabled = True
        ReadSingleFieldButton.Enabled = True
        DeleteSingleFieldButton.Enabled = True
        RegisterButton.Enabled = True
        Cursor.Current = Cursors.Default

    End Sub

    Private Sub DeleteSingleFieldButton_Click(sender As Object, e As EventArgs) Handles DeleteSingleFieldButton.Click


        CreateAndInsertButton.Enabled = False
        ReadAndModifyButton.Enabled = False
        ReadAndExportButton.Enabled = False
        ReadSingleFieldButton.Enabled = False
        DeleteSingleFieldButton.Enabled = False
        RegisterButton.Enabled = False
        Cursor.Current = Cursors.WaitCursor


        traditional_or_xml_format = 0 ' traditional format
        'traditional_or_xml_format = 1 ' NIEM-conformant XML format
        _SetAnsiNistItlVersion(2000, traditional_or_xml_format) ' NIEM-conformant XML format


        ' Sets input file name as "sample.nist" which located in "input" subdirectory
        filedirectory = program_file_path + "\input\"

        If (traditional_or_xml_format = 0) Then
            filename = filedirectory + "sample.nist"
        Else
            filename = filedirectory + "sample_NIEM_conformant_XML.xml"
        End If



        If Not File.Exists(filename) Then
            If (traditional_or_xml_format = 0) Then
                MessageBox.Show("Error: file .\input\sample.nist does not exist.")
            Else
                MessageBox.Show("Error: file .\input\sample_NIEM_conformant_XML.xml does not exist.")
            End If

            Return
        End If


        ' Reads NIST file, loads NIST file contents into memory and decodes NIST file data into
        ' usable format. This function must be called at the beginning (one time only) before
        ' any further processing of NIST file.
        _ReadNISTFromFile(utf8.GetBytes(filename))




        If (_CheckIfRecordTypeExists(2) = 1) Then

            ' Modifies NIST file, Deletes all Type-2 records
            type_2_number_of_records = _ReadNumberOfRecords(2)

            For i As Int32 = 1 To type_2_number_of_records
                ' idc = _ReadIDCofRecord(2, 1) ' selects the first Type-2 record
                idc = _ReadIDCofRecord(2, (type_2_number_of_records - i + 1)) ' selects the last Type-2 record
                _DeleteRecord(2, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(2) = 1) 


        If (_CheckIfRecordTypeExists(4) = 1) Then

            ' Modifies NIST file, Deletes all Type-4 records
            type_4_number_of_records = _ReadNumberOfRecords(4)

            For i As Int32 = 1 To type_4_number_of_records
                ' idc = _ReadIDCofRecord(4, 1) ' selects the first Type-4 record
                idc = _ReadIDCofRecord(4, (type_4_number_of_records - i + 1)) ' selects the last Type-4 record
                _DeleteRecord(4, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(4) = 1) 



        If (_CheckIfRecordTypeExists(7) = 1) Then

            ' Modifies NIST file, Deletes all Type-7 records
            type_7_number_of_records = _ReadNumberOfRecords(7)

            For i As Int32 = 1 To type_7_number_of_records
                ' idc = _ReadIDCofRecord(7, 1) ' selects the first Type-7 record
                idc = _ReadIDCofRecord(7, (type_7_number_of_records - i + 1)) ' selects the last Type-7 record
                _DeleteRecord(7, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(7) = 1) 


        If (_CheckIfRecordTypeExists(8) = 1) Then

            ' Modifies NIST file, Deletes all Type-8 records
            type_8_number_of_records = _ReadNumberOfRecords(8)

            For i As Int32 = 1 To type_8_number_of_records
                ' idc = _ReadIDCofRecord(8, 1) ' selects the first Type-8 record
                idc = _ReadIDCofRecord(8, (type_8_number_of_records - i + 1)) ' selects the last Type-8 record
                _DeleteRecord(8, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(8) = 1) 


        If (_CheckIfRecordTypeExists(9) = 1) Then

            ' Modifies NIST file, Deletes all Type-9 records
            type_9_number_of_records = _ReadNumberOfRecords(9)

            For i As Int32 = 1 To type_9_number_of_records
                ' idc = _ReadIDCofRecord(9, 1) ' selects the first Type-9 record
                idc = _ReadIDCofRecord(9, (type_9_number_of_records - i + 1)) ' selects the last Type-9 record
                _DeleteRecord(9, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(9) = 1) 


        If (_CheckIfRecordTypeExists(10) = 1) Then

            ' Modifies NIST file, Deletes all Type-10 records
            type_10_number_of_records = _ReadNumberOfRecords(10)

            For i As Int32 = 1 To type_10_number_of_records
                ' idc = _ReadIDCofRecord(10, 1) ' selects the first Type-10 record
                idc = _ReadIDCofRecord(10, (type_10_number_of_records - i + 1)) ' selects the last Type-10 record
                _DeleteRecord(10, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(10) = 1) 


        If (_CheckIfRecordTypeExists(11) = 1) Then

            ' Modifies NIST file, Deletes all Type-11 records
            type_11_number_of_records = _ReadNumberOfRecords(11)

            For i As Int32 = 1 To type_11_number_of_records
                ' idc = _ReadIDCofRecord(11, 1) ' selects the first Type-11 record
                idc = _ReadIDCofRecord(11, (type_11_number_of_records - i + 1)) ' selects the last Type-11 record
                _DeleteRecord(11, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(11) = 1) 


        If (_CheckIfRecordTypeExists(12) = 1) Then

            ' Modifies NIST file, Deletes all Type-12 records
            type_12_number_of_records = _ReadNumberOfRecords(12)

            For i As Int32 = 1 To type_12_number_of_records
                ' idc = _ReadIDCofRecord(12, 1) ' selects the first Type-12 record
                idc = _ReadIDCofRecord(12, (type_12_number_of_records - i + 1)) ' selects the last Type-12 record
                _DeleteRecord(12, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(12) = 1) 


        If (_CheckIfRecordTypeExists(13) = 1) Then

            ' Modifies NIST file, Deletes all Type-13 records, deletes all 14 WSQ images
            type_13_number_of_records = _ReadNumberOfRecords(13)

            For i As Int32 = 1 To type_13_number_of_records
                ' idc = _ReadIDCofRecord(13, 1) ' selects the first Type-13 record
                idc = _ReadIDCofRecord(13, (type_13_number_of_records - i + 1)) ' selects the last Type-13 record
                _DeleteRecord(13, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(13) = 1) 


        If (_CheckIfRecordTypeExists(14) = 1) Then

            ' Modifies NIST file, Deletes all Type-14 records, deletes all 14 WSQ images
            type_14_number_of_records = _ReadNumberOfRecords(14)

            For i As Int32 = 1 To type_14_number_of_records
                ' idc = _ReadIDCofRecord(14, 1) ' selects the first Type-14 record
                idc = _ReadIDCofRecord(14, (type_14_number_of_records - i + 1)) ' selects the last Type-14 record
                _DeleteRecord(14, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(14) = 1) 


        If (_CheckIfRecordTypeExists(15) = 1) Then

            ' Modifies NIST file, Deletes all Type-15 records, deletes all 15 WSQ images
            type_15_number_of_records = _ReadNumberOfRecords(15)

            For i As Int32 = 1 To type_15_number_of_records
                ' idc = _ReadIDCofRecord(15, 1) ' selects the first Type-15 record
                idc = _ReadIDCofRecord(15, (type_15_number_of_records - i + 1)) ' selects the last Type-15 record
                _DeleteRecord(15, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(15) = 1) 


        If (_CheckIfRecordTypeExists(16) = 1) Then

            ' Modifies NIST file, Deletes all Type-16 records, deletes all 16 WSQ images
            type_16_number_of_records = _ReadNumberOfRecords(16)

            For i As Int32 = 1 To type_16_number_of_records
                ' idc = _ReadIDCofRecord(16, 1) ' selects the first Type-16 record
                idc = _ReadIDCofRecord(16, (type_16_number_of_records - i + 1)) ' selects the last Type-16 record
                _DeleteRecord(16, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(16) = 1) 


        If (_CheckIfRecordTypeExists(17) = 1) Then

            ' Modifies NIST file, Deletes all Type-17 records
            type_17_number_of_records = _ReadNumberOfRecords(17)

            For i As Int32 = 1 To type_17_number_of_records
                ' idc = _ReadIDCofRecord(17, 1) ' selects the first Type-17 record
                idc = _ReadIDCofRecord(17, (type_17_number_of_records - i + 1)) ' selects the last Type-17 record
                _DeleteRecord(17, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(17) = 1) 


        If (_CheckIfRecordTypeExists(18) = 1) Then

            ' Modifies NIST file, Deletes all Type-18 records
            type_18_number_of_records = _ReadNumberOfRecords(18)

            For i As Int32 = 1 To type_18_number_of_records
                ' idc = _ReadIDCofRecord(18, 1) ' selects the first Type-18 record
                idc = _ReadIDCofRecord(18, (type_18_number_of_records - i + 1)) ' selects the last Type-18 record
                _DeleteRecord(18, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(18) = 1) 


        If (_CheckIfRecordTypeExists(19) = 1) Then

            ' Modifies NIST file, Deletes all Type-19 records
            type_19_number_of_records = _ReadNumberOfRecords(19)

            For i As Int32 = 1 To type_19_number_of_records
                ' idc = _ReadIDCofRecord(19, 1) ' selects the first Type-19 record
                idc = _ReadIDCofRecord(19, (type_19_number_of_records - i + 1)) ' selects the last Type-19 record
                _DeleteRecord(19, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(19) = 1) 


        If (_CheckIfRecordTypeExists(20) = 1) Then

            ' Modifies NIST file, Deletes all Type-20 records
            type_20_number_of_records = _ReadNumberOfRecords(20)

            For i As Int32 = 1 To type_20_number_of_records
                ' idc = _ReadIDCofRecord(20, 1) ' selects the first Type-20 record
                idc = _ReadIDCofRecord(20, (type_20_number_of_records - i + 1)) ' selects the last Type-20 record
                _DeleteRecord(20, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(20) = 1) 


        If (_CheckIfRecordTypeExists(21) = 1) Then

            ' Modifies NIST file, Deletes all Type-21 records
            type_21_number_of_records = _ReadNumberOfRecords(21)

            For i As Int32 = 1 To type_21_number_of_records
                ' idc = _ReadIDCofRecord(21, 1) ' selects the first Type-21 record
                idc = _ReadIDCofRecord(21, (type_21_number_of_records - i + 1)) ' selects the last Type-21 record
                _DeleteRecord(21, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(21) = 1) 


        If (_CheckIfRecordTypeExists(22) = 1) Then

            ' Modifies NIST file, Deletes all Type-22 records
            type_22_number_of_records = _ReadNumberOfRecords(22)

            For i As Int32 = 1 To type_22_number_of_records
                ' idc = _ReadIDCofRecord(22, 1) ' selects the first Type-22 record
                idc = _ReadIDCofRecord(22, (type_22_number_of_records - i + 1)) ' selects the last Type-22 record
                _DeleteRecord(22, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(22) = 1) 


        If (_CheckIfRecordTypeExists(98) = 1) Then

            ' Modifies NIST file, Deletes all Type-98 records
            type_98_number_of_records = _ReadNumberOfRecords(98)

            For i As Int32 = 1 To type_98_number_of_records
                ' idc = _ReadIDCofRecord(98, 1) ' selects the first Type-98 record
                idc = _ReadIDCofRecord(98, (type_98_number_of_records - i + 1)) ' selects the last Type-98 record
                _DeleteRecord(98, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(98) = 1) 


        If (_CheckIfRecordTypeExists(99) = 1) Then

            ' Modifies NIST file, Deletes all Type-99 records
            type_99_number_of_records = _ReadNumberOfRecords(99)

            For i As Int32 = 1 To type_99_number_of_records
                ' idc = _ReadIDCofRecord(99, 1) ' selects the first Type-99 record
                idc = _ReadIDCofRecord(99, (type_99_number_of_records - i + 1)) ' selects the last Type-99 record
                _DeleteRecord(99, idc)
            Next i

        End If ' If (_CheckIfRecordTypeExists(99) = 1) 


        ' Sets output file name as "sample_of_deletion.nist" (in "output" subdirectory)
        filedirectory = program_file_path + "\output\"
        If Not Directory.Exists(filedirectory) Then
            ' Create output directory
            Directory.CreateDirectory(filedirectory)
        End If

        If (traditional_or_xml_format = 0) Then
            filename = filedirectory + "sample_of_deletion.nist"
        Else
            filename = filedirectory + "sample_of_deletion.xml"
        End If


        ' Saves NIST into the file "sample_of_deletion.nist" (in "output" subdirectory)
        _WriteNISTToFile(utf8.GetBytes(filename))

        If (traditional_or_xml_format = 0) Then
            MessageBox.Show("NIST file " & Chr(34) & ".\input\sample.nist" & Chr(34) & " was read, modified" & vbCrLf & "and saved as " & Chr(34) & ".\output\sample_of_deletion.nist" & Chr(34) & "" & vbCrLf & vbCrLf & "Please use " & Chr(34) & "NIST viewer" & Chr(34) & " to see changes in" & vbCrLf & "" & Chr(34) & "sample_of_deletion.nist" & Chr(34) & " file.")
        Else
            MessageBox.Show("NIST file " & Chr(34) & ".\input\sample_NIEM_conformant_XML.xml" & Chr(34) & " was read, modified" & vbCrLf & "and saved as " & Chr(34) & ".\output\sample_of_deletion.xml" & Chr(34) & "" & vbCrLf & vbCrLf & "Please use " & Chr(34) & "NIST viewer" & Chr(34) & " to see changes in" & vbCrLf & "" & Chr(34) & "sample_of_deletion.xml" & Chr(34) & " file.")
        End If



        CreateAndInsertButton.Enabled = True
        ReadAndModifyButton.Enabled = True
        ReadAndExportButton.Enabled = True
        ReadSingleFieldButton.Enabled = True
        DeleteSingleFieldButton.Enabled = True
        RegisterButton.Enabled = True
        Cursor.Current = Cursors.Default


    End Sub

    Private Sub ReadAndModifyButton_Click(sender As Object, e As EventArgs) Handles ReadAndModifyButton.Click

        CreateAndInsertButton.Enabled = False
        ReadAndModifyButton.Enabled = False
        ReadAndExportButton.Enabled = False
        ReadSingleFieldButton.Enabled = False
        DeleteSingleFieldButton.Enabled = False
        RegisterButton.Enabled = False
        Cursor.Current = Cursors.WaitCursor

        traditional_or_xml_format = 0 ' traditional format
        ' traditional_or_xml_format = 1 ' NIEM-conformant XML format
        _SetAnsiNistItlVersion(2000, traditional_or_xml_format) ' NIEM-conformant XML format


        ' Sets input file name as "sample.nist" which located in "input" subdirectory
        filedirectory = program_file_path + "\input\"

        If (traditional_or_xml_format = 0) Then
            filename = filedirectory + "sample.nist"
        Else
            filename = filedirectory + "sample_NIEM_conformant_XML.xml"
        End If


        If Not File.Exists(filename) Then
            If (traditional_or_xml_format = 0) Then
                MessageBox.Show("Error: file .\input\sample.nist does not exist.")
            Else
                MessageBox.Show("Error: file .\input\sample_NIEM_conformant_XML.xml does not exist.")
            End If

            Return
        End If



        ' Reads NIST file
        _ReadNISTFromFile(utf8.GetBytes(filename))


        ' Modifies NIST file, inserts/replaces Type-1 record Type of transaction (TOT)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("TOT"), utf8.GetBytes("WSQ"))

        ' Modifies NIST file, inserts/replaces Type-1 record Date (DAT)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("DAT"), utf8.GetBytes("20080931"))
        Else
            _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("DAT"), utf8.GetBytes("2008-09-31"))
        End If

        ' Modifies NIST file, inserts/replaces Type-1 record Priority (PRY)
        ' The length of Priority (PRY) field must be equal to 1 bytes
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("PRY"), utf8.GetBytes("2"))

        ' Modifies NIST file, inserts/replaces Type-1 record Destination agency identifier (DAI)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("DAI"), utf8.GetBytes("Central Intelligence Agency"))

        ' Modifies NIST file, inserts/replaces Type-1 record Originating agency identifier (ORI)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("ORI"), utf8.GetBytes("Police Station"))

        ' Modifies NIST file, inserts/replaces Type-1 record Transaction control number (TCN)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("TCN"), utf8.GetBytes("000000123"))

        ' Modifies NIST file, inserts/replaces Type-1 record Transaction control reference (TCR)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("TCR"), utf8.GetBytes("000000987"))

        ' Modifies NIST file, inserts/replaces Type-1 record Native scanning resolution(NSR)
        ' The length of Native scanning resolution(NSR) field must be equal to 5 bytes
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("NSR"), utf8.GetBytes("21.33"))

        ' Modifies NIST file, inserts/replaces Type-1 record Nominal transmitting resolution (NTR)
        ' The length of Nominal transmitting resolution (NTR) field must be equal to 5 bytes
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("NTR"), utf8.GetBytes("21.33"))

        ' Modifies NIST file, inserts/replaces Type-1 record Domain name (DOM)
        _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("DOM"), utf8.GetBytes("NORAM"))

        ' Modifies NIST file, inserts/replaces Type-1 record Greenwich mean time (GMT)
        ' The length of Greenwich mean time (GMT) field must be equal to 15 bytes
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("GMT"), utf8.GetBytes("20080931170316Z"))
        Else
            _InsertRecordTxtField(1, -1, -1, utf8.GetBytes("GMT"), utf8.GetBytes("2008-09-31T17:03:16Z"))
        End If


        ' Modifies NIST file, inserts two Type-2 records,
        ' if these records already exist then they are overwritten and replaced
        idc = 0
        _InsertRecordTxtField(2, idc, 30, utf8.GetBytes(""), utf8.GetBytes("William Thompson"))
        _InsertRecordTxtField(2, idc, 31, utf8.GetBytes(""), utf8.GetBytes("Kelvin"))



        ' Sets input directory as "input" subdirectory of the program location
        filedirectory = program_file_path + "\\input\\"


        ' Modifies NIST file, inserts Type-4 records.
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced

        filename = filedirectory + "type4_left_thumb.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, 7, utf8.GetBytes(filename))


        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("6"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))


        filename = filedirectory + "type4_right_thumb.wsq"
        idc_current = _InsertRecordBinaryFieldFromFile(4, 12, utf8.GetBytes(filename))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("3"))
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP1"), utf8.GetBytes("1"))
        ' FGP2 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP2"), "255")
        ' FGP3 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP3"), "255")
        ' FGP4 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP4"), "255")
        ' FGP5 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP5"), "255")
        ' FGP6 value of "255" was already inserted by default when creating Type-4 record
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("FGP6"), "255")
        _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("ISR"), utf8.GetBytes("1"))
        ' HLL value of image width was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("HLL"), utf8.GetBytes("0"))
        ' VLL value of image height was already inserted by default when creating Type-4 record, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("VLL"), utf8.GetBytes("0"))
        ' "NIST library" inserts GCA value utf8.GetBytes("1") automatically when creating Type-4 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(4, idc_current, -1, utf8.GetBytes("GCA"), utf8.GetBytes("1"))



        ' Modifies NIST file, inserts Type-10 records.
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced

        filename = filedirectory + "type10_Charles_Luciano_frontal.jpg"


        idc_current = _InsertRecordBinaryFieldFromFile(10, 23, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
        ' _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("IMT") ,utf8.GetBytes("FACE"))
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("IMT"), utf8.GetBytes("SCAR"))


        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("20091217"))
        Else
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("2009-12-17"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (THPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("300"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("300"))

        ' "NIST library" inserts CGA value "JPEGB" automatically when creating Type-10 record, based on filename *.jpg extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CGA"), "JPEGB")

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)   
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CSP"), utf8.GetBytes("RGB"))
        ' _InsertRecordTxtField(10, idc_current, 12, utf8.GetBytes(""), utf8.GetBytes("RGB"))

        ' Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("POS"), utf8.GetBytes("F"))  ' Full Face Frontal




        filename = filedirectory + "type10_Charles_Luciano_profile.jpg"

        idc_current = _InsertRecordBinaryFieldFromFile(10, 24, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Image type (IMT)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("IMT"), utf8.GetBytes("FACE"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Source agency / ORI (SRC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Photo date (PHD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("20091217"))
        Else
            _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("PHD"), utf8.GetBytes("2009-12-17"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Scale units (SLC)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("1"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Horizontal pixel scale (THPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("300"))

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("300"))

        ' "NIST library" inserts CGA value "PNG" automatically when creating Type-10 record, based on filename *.jp2 extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CGA"), "JPG")

        ' Modifies NIST file, inserts/replaces mandatory Type-10 record Colorspace (CSP)   
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("CSP"), utf8.GetBytes("RGB"))
        ' _InsertRecordTxtField(10, idc_current, 12, utf8.GetBytes(""), utf8.GetBytes("RGB"))

        ' Modifies NIST file, inserts/replaces Type-10 record Subject pose (POS)
        _InsertRecordTxtField(10, idc_current, -1, utf8.GetBytes("POS"), utf8.GetBytes("R"))  ' Right Profile


        ' Modifies NIST file, inserts Type-14 records.
        ' If the record with specified IDC number already exists in *.nist file,
        ' then existing old record is overwritten and replaced

        filename = filedirectory + "type14_replace_01.wsq"

        idc_current = _InsertRecordBinaryFieldFromFile(14, 27, utf8.GetBytes(filename))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Impression type (IMP)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("IMP"), utf8.GetBytes("0"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Source agency / ORI (SRC)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("SRC"), utf8.GetBytes("Cognaxon"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Tenprint capture date (TCD)
        If (traditional_or_xml_format = 0) Then
            _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("TCD"), utf8.GetBytes("19990923"))
        Else
            _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("TCD"), utf8.GetBytes("1999-09-23"))
        End If

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Scale units (SLC)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("SLC"), utf8.GetBytes("2"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Horizontal pixel scale (THPS)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("THPS"), utf8.GetBytes("197"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Vertical pixel scale (TVPS)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("TVPS"), utf8.GetBytes("197"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Compression algorithm (CGA)
        ' "NIST library" inserts CGA value "WSQ20" automatically when creating Type-14 record, based on filename *.wsq extension, here you can overwrite it with new value if needed
        ' _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("CGA") ,"WSQ20")

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Bits per pixel (BPX)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("BPX"), utf8.GetBytes("8"))

        ' Modifies NIST file, inserts/replaces mandatory Type-14 record Finger position (FGP)
        _InsertRecordTxtField(14, idc_current, -1, utf8.GetBytes("FGP"), utf8.GetBytes("14"))




        ' Sets output file name as "sample_modified.nist" (in "output" subdirectory)
        filedirectory = program_file_path + "\output\"
        If Not Directory.Exists(filedirectory) Then
            ' Create output directory
            Directory.CreateDirectory(filedirectory)
        End If


        If (traditional_or_xml_format = 0) Then
            filename = filedirectory + "sample_modified.nist"
        Else
            filename = filedirectory + "sample_modified.xml"
        End If

        ' Saves NIST into the file "sample_modified.nist" (in "output" subdirectory)
        _WriteNISTToFile(utf8.GetBytes(filename))

        If (traditional_or_xml_format = 0) Then
            MessageBox.Show("NIST file " & Chr(34) & ".\input\sample.nist" & Chr(34) & " was read, modified" & vbCrLf & "and saved as " & Chr(34) & ".\output\sample_modified.nist" & Chr(34) & "" & vbCrLf & vbCrLf & "Please use " & Chr(34) & "NIST viewer" & Chr(34) & " to see changes in" & vbCrLf & "" & Chr(34) & "sample_modified.nist" & Chr(34) & " file.")
        Else
            MessageBox.Show("NIST file " & Chr(34) & ".\input\sample_NIEM_conformant_XML.xml" & Chr(34) & " was read, modified" & vbCrLf & "and saved as " & Chr(34) & ".\output\sample_modified.xml" & Chr(34) & "" & vbCrLf & vbCrLf & "Please use " & Chr(34) & "NIST viewer" & Chr(34) & " to see changes in" & vbCrLf & "" & Chr(34) & "sample_modified.xml" & Chr(34) & " file.")
        End If



        CreateAndInsertButton.Enabled = True
        ReadAndModifyButton.Enabled = True
        ReadAndExportButton.Enabled = True
        ReadSingleFieldButton.Enabled = True
        DeleteSingleFieldButton.Enabled = True
        RegisterButton.Enabled = True
        Cursor.Current = Cursors.Default

    End Sub
End Class



