Imports System.IO
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.Data.Odbc
Public Class importCCFtoMARC '/////Develope by Dinesh Rayka INFLIBNET Centre

    Inherits System.Windows.Forms.Form
    Dim RecId As Integer = 1
    Dim dbcon As New Connection
    Dim reccounter As Long
    Dim longRecordCounter As Long = 1
    Dim ArrLength, ArrayCount As Integer
    Dim MarcRecID As Long = 1
    Dim rowNo As Integer = 0
    Dim strdirstruct As String
    Dim strdatastruct As String
    Dim csvFile As String
    Dim csvFile2 As String

    Dim BadRecord As String = ""
    Dim BadFilePath As String
    Dim outFile, outFile2 As IO.StreamWriter
    Friend WithEvents sbsearch As System.Windows.Forms.StatusBar
    Friend WithEvents pnldatabase As System.Windows.Forms.StatusBarPanel
    Friend WithEvents PMAX As System.Windows.Forms.StatusBarPanel
    Friend WithEvents pnlcount As System.Windows.Forms.StatusBarPanel
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents lblimfs As System.Windows.Forms.Label
    'Dim MarcRecID As Integer = 1
    'RecordSep = "#"
    Dim Bool As Boolean = False
    Dim ChkBadBool As Boolean = False
    Friend WithEvents SaveBadCCFFileDialog As System.Windows.Forms.SaveFileDialog
    Dim FolderLocation As String


#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 btnSelectFile As System.Windows.Forms.Button
    Friend WithEvents txtFileToImport As System.Windows.Forms.TextBox
    Friend WithEvents lblFile As System.Windows.Forms.Label
    Friend WithEvents btnImport As System.Windows.Forms.Button
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents OpenccfFileDialog As System.Windows.Forms.OpenFileDialog
    Friend WithEvents btnExit As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnSelectFile = New System.Windows.Forms.Button
        Me.txtFileToImport = New System.Windows.Forms.TextBox
        Me.lblFile = New System.Windows.Forms.Label
        Me.btnImport = New System.Windows.Forms.Button
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        Me.btnExit = New System.Windows.Forms.Button
        Me.sbsearch = New System.Windows.Forms.StatusBar
        Me.pnldatabase = New System.Windows.Forms.StatusBarPanel
        Me.PMAX = New System.Windows.Forms.StatusBarPanel
        Me.pnlcount = New System.Windows.Forms.StatusBarPanel
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.lblimfs = New System.Windows.Forms.Label
        Me.SaveBadCCFFileDialog = New System.Windows.Forms.SaveFileDialog
        CType(Me.pnldatabase, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.PMAX, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.pnlcount, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'btnSelectFile
        '
        Me.btnSelectFile.BackColor = System.Drawing.Color.Transparent
        Me.btnSelectFile.FlatAppearance.BorderSize = 0
        Me.btnSelectFile.Font = New System.Drawing.Font("Arial Unicode MS", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnSelectFile.Location = New System.Drawing.Point(430, 52)
        Me.btnSelectFile.Name = "btnSelectFile"
        Me.btnSelectFile.Size = New System.Drawing.Size(86, 25)
        Me.btnSelectFile.TabIndex = 0
        Me.btnSelectFile.Text = "Browse"
        Me.btnSelectFile.UseVisualStyleBackColor = False
        '
        'txtFileToImport
        '
        Me.txtFileToImport.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtFileToImport.Location = New System.Drawing.Point(190, 52)
        Me.txtFileToImport.Multiline = True
        Me.txtFileToImport.Name = "txtFileToImport"
        Me.txtFileToImport.Size = New System.Drawing.Size(234, 24)
        Me.txtFileToImport.TabIndex = 1
        '
        'lblFile
        '
        Me.lblFile.BackColor = System.Drawing.Color.FromArgb(CType(CType(185, Byte), Integer), CType(CType(209, Byte), Integer), CType(CType(240, Byte), Integer))
        Me.lblFile.Font = New System.Drawing.Font("Arial Unicode MS", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblFile.Location = New System.Drawing.Point(6, 52)
        Me.lblFile.Name = "lblFile"
        Me.lblFile.Size = New System.Drawing.Size(178, 23)
        Me.lblFile.TabIndex = 2
        Me.lblFile.Text = "Select CCF file for Import"
        Me.lblFile.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'btnImport
        '
        Me.btnImport.BackColor = System.Drawing.Color.Transparent
        Me.btnImport.FlatAppearance.BorderSize = 0
        Me.btnImport.Font = New System.Drawing.Font("Arial Unicode MS", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnImport.Location = New System.Drawing.Point(516, 52)
        Me.btnImport.Name = "btnImport"
        Me.btnImport.Size = New System.Drawing.Size(86, 25)
        Me.btnImport.TabIndex = 3
        Me.btnImport.Text = "Import"
        Me.btnImport.UseVisualStyleBackColor = False
        '
        'OpenFileDialog1
        '
        '
        'btnExit
        '
        Me.btnExit.BackColor = System.Drawing.Color.Transparent
        Me.btnExit.FlatAppearance.BorderSize = 0
        Me.btnExit.Font = New System.Drawing.Font("Arial Unicode MS", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnExit.Location = New System.Drawing.Point(602, 52)
        Me.btnExit.Name = "btnExit"
        Me.btnExit.Size = New System.Drawing.Size(86, 25)
        Me.btnExit.TabIndex = 11
        Me.btnExit.Text = "Close"
        Me.btnExit.UseVisualStyleBackColor = False
        '
        'sbsearch
        '
        Me.sbsearch.Font = New System.Drawing.Font("Arial", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.sbsearch.Location = New System.Drawing.Point(0, 106)
        Me.sbsearch.Name = "sbsearch"
        Me.sbsearch.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.pnldatabase, Me.PMAX, Me.pnlcount})
        Me.sbsearch.ShowPanels = True
        Me.sbsearch.Size = New System.Drawing.Size(773, 24)
        Me.sbsearch.TabIndex = 21
        '
        'pnldatabase
        '
        Me.pnldatabase.Name = "pnldatabase"
        Me.pnldatabase.Text = "Total Records"
        Me.pnldatabase.Width = 90
        '
        'PMAX
        '
        Me.PMAX.Name = "PMAX"
        Me.PMAX.Width = 75
        '
        'pnlcount
        '
        Me.pnlcount.Name = "pnlcount"
        Me.pnlcount.Text = "Imported :"
        Me.pnlcount.Width = 250
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.lblimfs)
        Me.GroupBox1.Controls.Add(Me.lblFile)
        Me.GroupBox1.Controls.Add(Me.btnSelectFile)
        Me.GroupBox1.Controls.Add(Me.txtFileToImport)
        Me.GroupBox1.Controls.Add(Me.btnExit)
        Me.GroupBox1.Controls.Add(Me.btnImport)
        Me.GroupBox1.Location = New System.Drawing.Point(27, 5)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(729, 95)
        Me.GroupBox1.TabIndex = 23
        Me.GroupBox1.TabStop = False
        '
        'lblimfs
        '
        Me.lblimfs.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(128, Byte), Integer), CType(CType(128, Byte), Integer))
        Me.lblimfs.Font = New System.Drawing.Font("Arial", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblimfs.Location = New System.Drawing.Point(187, 16)
        Me.lblimfs.Name = "lblimfs"
        Me.lblimfs.Size = New System.Drawing.Size(437, 22)
        Me.lblimfs.TabIndex = 12
        Me.lblimfs.Text = "Note: field Saparater= # , Record Saparater= ##  , Subfiels Saparater = ^"
        Me.lblimfs.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'SaveBadCCFFileDialog
        '
        Me.SaveBadCCFFileDialog.Filter = "All Files |*.*|Text Files *.txt|*.txt"
        '
        'importCCFtoMARC
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(185, Byte), Integer), CType(CType(209, Byte), Integer), CType(CType(240, Byte), Integer))
        Me.ClientSize = New System.Drawing.Size(773, 130)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.sbsearch)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Name = "importCCFtoMARC"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Import CCF Records"
        CType(Me.pnldatabase, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.PMAX, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.pnlcount, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btnSelectFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectFile.Click
        txtFileToImport.Clear()
        OpenFileDialog1.FilterIndex = 1
        OpenFileDialog1.Filter = "Text Files(*.txt)|*.txt| All Files(*.*)|*.*"
        OpenFileDialog1.ShowDialog() 'this will show browser
        btnImport.Enabled = True
        longRecordCounter = 1
    End Sub
    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        txtFileToImport.Text = OpenFileDialog1.FileName
    End Sub

    Private Sub btnImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport.Click
        'for only ANSI encoding
        'PictureBox1.Visible = True
        'Develope by Dinesh Rayka INFLIBNET Centre
        Bool = False
        Dim record As String
        Dim BadRecCount As Integer = 0
        Try
            'u will get  file location here
            FolderLocation = Application.StartupPath & "\Data.csv"
            'File.Delete(FolderLocation)
            'csvFile = FolderLocation
            'define bibliographic details dataset
            Dim BibRecIDDS As New Data.DataSet
            Dim i As Integer
            'Get Max Record ID from File 
            Dim strgetRecid As String = "SELECT Max(RecId) FROM " & FolderLocation & ""
            BibRecIDDS = dbcon.CreateDS(strgetRecid)
            'Get Maximum Record id from File
            Try
                'check for record id value,  if null then assgn 1 as a record id otherwise add 1 in existing maximum record id value
                If BibRecIDDS.Tables(0).Rows(0).IsNull(0) = True Then
                    RecId = 1
                Else
                    RecId = BibRecIDDS.Tables(0).Rows(0).Item(0)
                    'FileOpen(2, Application.StartupPath & "\Data.csv", OpenMode.Binary) 'bad record is come then it is set in "c:\BadRecord\record.txt
                End If
            Catch ex As Exception
                'MsgBox(ex.ToString)
                RecId = 0
            End Try
            PMAX.Text = RecId
            dbcon.objDataset1.Clear()
            'Read text file
            FileOpen(1, txtFileToImport.Text, OpenMode.Binary)
            Dim strCharacter As New String(" ", 1) 'TO get a  character from file
            Dim longPosition As Long = 1 'To set the position of pointer infile
            Dim strRecord As String 'TO get whole record containing Leader,Directory Structure,Record of tags
            ' Dim strlable As String
            Dim strBool As Boolean
            'Dim strDirStructure As String
            ' Dim strRec As String 'To get record string for a perticular record
            Dim RecordSep As String
            Dim FieldSep As String
            'Dim strdirstruct As String
            'Dim strdatastruct As String
            Dim strfieldsep As String
            Dim y As Boolean
            Dim str As String = Nothing
            ChkBadBool = True
            'Dim strvalue As String
            'Dim strvaluestruct As String
            RecordSep = "#"
            FieldSep = "#"
            While Not EOF(1)
                Seek(1, longPosition) 'Starts reading from the first character of file
                FileGet(1, strCharacter) 'Get character on that position(which longposition gives)
                If strBool = True Then
                    'here check the second Record sep
                    If strCharacter = RecordSep Then
                        str = Trim(str)
                        'MsgBox(strRecord & strCharacter)
                        strdatastruct = str & strCharacter  'here we will get record aftre firs Record sep. to Second Recordsep.
                        'strdatastruct = Trim(strdatastruct)
                        'MsgBox(str & strCharacter)
                        'Following Function will diffrent Tag and Directory
                        CCFSplitter(strdirstruct, strdatastruct, strfieldsep)
A:
                        str = " "
                        strCharacter = " "
                        'If strCharacter = " " Then
                        '    longPosition += 1
                        'End If
                        longPosition += 1
                        strRecord = " "
                        strdirstruct = ""
                        y = False   ' here loop will get next record
                    End If
                End If
                Try
                    If Asc(strCharacter) <> 29 Then 'Chek if it is not record delimiter                         
                        If strCharacter <> Chr(10) Then
                            If strCharacter = RecordSep Then 'here if strcharacter=recordsep then  will get only
                                strRecord = strRecord
                                strRecord = Trim(strRecord)
                            Else
                                strRecord = strRecord & strCharacter 'Add that character to string
                                strRecord = Trim(strRecord)
                            End If
                            If strCharacter = RecordSep Then  ' here we can splite the record till first RECORD SEP come
                                y = True
                                If strdirstruct = "" Then
                                    strdirstruct = strRecord  'here we will get the record before first RECORD SEP 
                                End If
                                strBool = True
                            Else
                                strBool = False
                            End If
                            If y = True Then
                                str = str & strCharacter
                            End If
                        End If
                    End If
                Catch
                End Try
                longPosition += 1 'increment position
                'PMAX.Text = longPosition
            End While
        Catch ex As Exception
            'Dim record As String
            ''MessageBox.Show("RecID " & longRecordCounter & "     " & ex.ToString, "Import", MessageBoxButtons.OK, MessageBoxIcon.Error)
            'record = strdirstruct & strdatastruct
            'If File.Exists("D:\Record.txt") Then
            '    FilePut(2, "" & Chr(13) & Chr(10) & record)
            'Else
            '    FileOpen(2, "D:\Record.txt", OpenMode.Binary) 'bad record is come then it is set in "c:\BadRecord\record.txt
            '    FilePut(2, "" & record)
            'End If
            'BadRecCount = BadRecCount + 1
            If ChkBadBool = False Then
                'MsgBox("Test")
                'MsgBox(MarcRecID)
                Dim DelBadRecDS As DataSet

                DelBadRecDS = dbcon.CreateDS("delete FROM " & FolderLocation & " where recid='" & RecId & "'")
            End If
            BadRecord = BadRecord & Chr(13) & Chr(10) & record
            Bool = True
            GoTo A
        End Try
        'lblRec.Text = reccounter
        pnlcount.Text = "Total Imported Records : " & longRecordCounter - 1

        Try
            If Bool = True Then
                Dim msg = MsgBox("Do you want to save Bad Records?", MsgBoxStyle.YesNo, "Conversion Utility")
                If msg = MsgBoxResult.Yes Then
                    SaveBadCCFFileDialog.ShowDialog()
                End If
                ' BadFilePath = "D:\badrecords.txt"
                If File.Exists(BadFilePath) Then
                    FilePut(2, BadRecord)
                Else
                    'Append bad record
                    FileOpen(2, BadFilePath, OpenMode.Binary) 'bad record is come then it is set in "c:\BadRecord\record.txt
                    FilePut(2, BadRecord)
                End If
            End If

        Catch ex As Exception

        End Try

        MessageBox.Show("Data Imported", "Import", MessageBoxButtons.OK, MessageBoxIcon.Information)
        btnImport.Enabled = False
        Bool = False
        btnSelectFile.Enabled = True

        txtFileToImport.Clear()
        FileClose(1)
        'outFile2.Close()
        FileClose(2)
        GetMaxRec()
        btnSelectFile.Enabled = True
    End Sub

    Private Function CCFSplitter(ByVal StrDirStruct As String, ByVal StrDataStruct As String, ByVal StrFieldSep As String)
        Dim DirCount As Long       'Temporary variable to get position of next tag in directory
        Dim strTagDir As String    'To get single directory
        Dim longIteration As Long
        Dim TagCount() As String
        Dim strTag As String
        Dim longItr As Long
        Dim strTagRecord As String
        ' Dim RecordSep As String
        Dim strFinalDir As String
        Dim characterCount As Long
        Dim CCFTable As DataTable
        Dim strSubfield As String
        Dim strvalue As String
        Dim SubFieldSap As Char
        Dim TSrNo As Long
        ' Dim TagSrNo As Long
        SubFieldSap = "^"
        Dim i As Integer ', x 
        ReDim Preserve TagCount(0)
        ' Dim strPrevTag As String
        'MsgBox(StrDirStruct)
        'here remove the new line from directoryStruct
        StrDirStruct = Trim(StrDirStruct)
        StrDirStruct = RemoveNewLine(StrDirStruct)

        'here remove the newline from  DataStruct
        ' StrDataStruct = Trim(StrDataStruct)
        StrDataStruct = RemoveNewLine(StrDataStruct)
        '. Get String which is containing Directory Structure
        ' Remove positions 0 to 23 (24 Charecters) , This will give you exact directory
        strFinalDir = Mid(StrDirStruct, 25, StrDirStruct.Length)
        ' FinalDir = Mid(str, 25, str.Length)
        'MsgBox("Final Dir:" & FinalDir)
        strFinalDir = Trim(strFinalDir)
        '3. Count Number of Character of Value we have got in 2 and Divide it by 12
        characterCount = strFinalDir.Length / 12 ' This will also help in finding loop count
        'Start the loop   
        'here we will get directory from finala Directory Directory=0 to 12
        'CREATE A TABLE with fields srno,Tag,Subfield,Value 
        CCFTable = New DataTable("CCFBibliDetail")
        Try
            'declare the columh here
            Dim SrNo As DataColumn = New DataColumn("SrNo")
            SrNo.DataType = System.Type.GetType("System.String")           'setting the datatype for the column
            'adding the column to table
            CCFTable.Columns.Add("SrNo")
            Dim Tag As DataColumn = New DataColumn("Tag")
            Tag.DataType = System.Type.GetType("System.String")
            CCFTable.Columns.Add(Tag)
            Dim SubField As DataColumn = New DataColumn("SubField")
            SubField.DataType = System.Type.GetType("System.String")
            CCFTable.Columns.Add(SubField)
            Dim value As DataColumn = New DataColumn("value")
            value.DataType = System.Type.GetType("System.String")
            CCFTable.Columns.Add(value)
        Catch
        End Try
        'binding the table to datagrid
        Dim dsCCFTable As New DataSet()
        dsCCFTable = New DataSet()
        'creating a dataset
        dsCCFTable.Tables.Add(CCFTable)
        'adding the table to dataset 
        'DataGrid1.SetDataBinding(dsCCFTable, "CCFBibliDetail")
        For longIteration = 0 To characterCount - 1
            'Each directiry is 12 character long
            strTagDir = strFinalDir.Substring(DirCount, 12)
            TSrNo = i

            'For longItr = 0 To TagCount.GetLength(0) - 1
            '    If TagCount(longItr) = strTagDir.Substring(0, 3) Then
            '        TagSrNo += 1
            '    End If
            'Next
            'ReDim Preserve TagCount(longIteration - 1)
            'TagCount(longIteration - 1) = strTagDir.Substring(0, 3)

            'strPrevTag = strTagDir.Substring(0, 3)

            'here we will get the tag from StrTag directory
            strTag = strTagDir.Substring(0, 3)
            'here we will get the datafor perticular tag ex. 001 tag contain ^a9 
            strTagRecord = StrDataStruct.Substring(CType(strTagDir.Substring(7, 5), Long) + 1, CType(strTagDir.Substring(3, 4), Long) - 1)
            'call a function with Parameter (Table,TAG,TagRecord) 

            FillCCFTable(CCFTable, TSrNo, strTag, strSubfield, strvalue, strTagRecord)
            i = i + 1
            DirCount = DirCount + 12  'So that we can get next directory(starts from longtemp2th position)
            'MARCMaker(CCFTable)
        Next
        ' Following Function will try to Get Splitted Marc Field
        MARCMaker(CCFTable)
        longRecordCounter += 1
        pnlcount.Text = longRecordCounter - 1 & " Records are imported"
        'MsgBox(longRecordCounter)        
    End Function
    Private Function FillCCFTable(ByVal CCFTable As DataTable, ByVal TSrNo As String, ByVal strTag As String, ByVal strSubfield As String, ByVal strvalue As String, ByVal StrTagRecord As String)
        'Append the values in the table 1 Sr.No , 2. Tag , 3. Subfield ,4 Value
        'Dim CCFRowCol As DataRowCollection
        Dim CCFRow As DataRow
        Dim SubFieldSap As Char
        SubFieldSap = "^"
        Dim strval As String
        ' Dim strTagSubField As String
        Dim strtagvalue As String
        '  Dim strtagval As String
        Dim sapIndex As Integer
        Dim length As Integer
        Dim i As Integer
        ' Dim TagSrNo As Long
        'Get the record       
        'Split the record with '^' and charecter next to that subfield
        'here  splite the tagrecord and get the subfield after "^" 
        i = 0
        Do
            ''declaring a new row 
            CCFRow = CCFTable.NewRow()
            CCFRow.Item("SrNo") = TSrNo
            CCFRow.Item("Tag") = strTag
            Try
                ' here we will get the subfield from strrecord 
                strSubfield = StrTagRecord.Substring(0, 2)
                'add the subfield to table's row
                CCFRow.Item("Subfield") = strSubfield
                length = Len(StrTagRecord)
                'here get the value after subfield
                strval = StrTagRecord.Substring(2, length - 2)
                'check the strvale have any other subfield ?
                sapIndex = strval.IndexOf(SubFieldSap)
                If sapIndex < 0 Then
                    CCFRow.Item("value") = strval
                Else
                    strtagvalue = strval.Substring(0, sapIndex)
                    CCFRow.Item("value") = strtagvalue
                    StrTagRecord = strval.Substring(sapIndex, Len(strval) - sapIndex)
                    '  strTagSubField = StrTagRecord.Substring(0, 2)
                    ' CCFRow.Item("Subfield") = strTagSubField
                End If
                i += 1
                CCFTable.Rows.Add(CCFRow)
            Catch
            End Try
        Loop While sapIndex > 0
        'GETTagVal(CCFTable, strTag, strSubfield)
        'Return Table
    End Function
    'Following Function will Remove New Line
    Private Function RemoveNewLine(ByVal InString As String)
        Dim NlIndex As Integer
        Dim NlLastIndex As Integer
        Dim StrFinalRet As String
        Dim CharNewLine As Char
        CharNewLine = Chr(13)
        'here we will get the first newline character
        NlIndex = InString.IndexOf(CharNewLine)
        NlLastIndex = InString.LastIndexOf(CharNewLine)
        If NlIndex <> -1 And NlLastIndex <> -1 Then
            'in the loop remove the all newline character of record and after the loop we will get record in one line
            Do While (NlIndex <= NlLastIndex And NlIndex <> -1)
                'MsgBox(InString.IndexOf(Chr(13)))
                'If InString.IndexOf(Chr(13)) = -1 Then
                StrFinalRet = InString.Remove(NlIndex, 1)
                'Else
                '    StrFinalRet = InString.Remove(NlIndex - 1, 2)
                'End If
                InString = StrFinalRet
                NlLastIndex = InString.LastIndexOf(CharNewLine)
                NlIndex = InString.IndexOf(CharNewLine)
            Loop
            Return StrFinalRet
        Else
            StrFinalRet = InString
            Return StrFinalRet
        End If
    End Function
    Private Function GETTagVal(ByRef CCFTable As DataTable, ByVal strTag As String, ByVal strSubfield As String, ByRef CCFVal() As String)
        Dim TableIteration As Integer
        Dim Tagval(1) As String
        Dim LowerVal As Integer ', TagSrNo
        Dim UpperVal As Integer
        Dim ArrayElement As Integer
        Dim TagSubField(1) As String
        Dim SubField As String
        ArrayElement = 0
        Tagval(0) = "Tag Not Available"
        TagSubField(0) = "Tag Not Available"
        'MsgBox(CCFTable.Rows.Count)
        For TableIteration = 0 To CCFTable.Rows.Count - 1
            Tag = CCFTable.Rows(TableIteration).Item("Tag")
            SubField = CCFTable.Rows(TableIteration).Item("SubField")
            'MsgBox(Tag)
            If Tag = strTag And SubField = strSubfield Then
                ReDim Preserve Tagval(ArrayElement + 1)
                '
                Tagval(ArrayElement) = CCFTable.Rows(TableIteration).Item("Value")
                'TagSubField(ArrayElement) = CCFTable.Rows(TableIteration).Item("Value")
                'MsgBox(Tagval(ArrayElement))
                ArrayElement = ArrayElement + 1
            End If
            'TableIteration = TableIteration + 1
        Next
        LowerVal = LBound(Tagval)
        'MsgBox(LowerVal)
        UpperVal = UBound(Tagval)
        'MsgBox(UpperVal)
        For TableIteration = LowerVal To UpperVal - 1
            'MsgBox(Tagval(TableIteration))
            ReDim Preserve CCFVal(TableIteration)
            CCFVal(TableIteration) = Tagval(TableIteration)
            'MsgBox(CCFVal)
        Next

    End Function
    Private Function MARCMaker(ByRef CCFTable As DataTable)
        Dim M000, M007, M008, Mfxfld00to05, MFixFLd00to05, Mfxfld06, Mfxfld7to10, Mfixfld7to10, Mfxfld07to10, Mfixfld07to10, Mfxfld11to14, Mfxfld15to17, Mfxfld18to21, Mfxfld22, Mfxfld23, Mfxfld24to27, Mfxfld28, Mfxfld29, Mfxfld30, Mfxfld31, Mfxfld32, Mfxfld33, Mfxfld34, Mfxfl035to37, Mfxfl35to37, Mfxfld38, Mfxfld39, M016, M020c, M020a, M020z, M022a, M022y, M022z, M027, M030, M040a, M040e, M040b, M041a, M044a, M050a, M050b, M080, M080b, M084b, M082, M082b, M084, M088a, M090, M100, M100a, M100f, M100ab, M110a, M110b, M110c, M110l, M111a, M711a, M111e, M711e, M711c, M111c, M711d, M111d, M130, M210a, M130FI2, M130FI3, M130FI4, M130FI0, M130n, M130k, M130p, M130c, M130s, M222SI0a, M222SI2a, M222SI3a, M222SI4a, M240SI0a, M240SI2a, M240SI3a, M240SI4a, M245c, M245b, M245a, MSls245, M245, M245p, M245SI2a, M245SI3a, M245SI4a, M245SI0a, M245c203a, M245ab As String
        Dim M246, M246a, M250a, M250b, M260a, M260b, M260c, M260e, M260f, M270a, M270d, M300a, M300b, M300c, M300e, M362, M362a, M365b, M365e, M365f, M440SI2a, M440SI3a, M440SI4a, M440SI0a, M440a, M440b, M440v, M440x, M700a, M710a, M710b, M710c, M710l, M490a, M490b, M490ab, M490, M490v, M490x, M500, M500a, M501a, M504a, M505, M505a, M530, M530a, M650, M650c, M650a, M651a, M648a, M653a, M740, M740FI2a, M740FI3a, M740FI4a, M740FI0a, M740n, M700, M700ab, M800, M800a, M850, M850a, M852, M852a, M852m, M852p, M852k As String
        Dim MChkDtVal, MChkSbFldsVal, MChkFISbFildsVal, MChkSISbFildsVal, MClaS, Marc653a, MChkSubFieldsVal, MChkSISbFlds240Val, M362aa, MChkSI440SbFldsVal, M440ab, M245csls, M730FI0, M730FI2, M730FI3, M653, M730FI4, M501ChkSbFldsVal, M740ChkSbFldsVal, M245Chkval As String
        Dim strbool, strboole As Boolean
        Dim CollFIndex, CollLIndex As Integer
        Dim StrTag As String
        Dim MarcTagSrNo As Integer
        Dim MarcTagSbFldSrNo As Integer
        'MarcRecID = 10000
        ChkBadBool = False
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        Dim RetCCFVal(0) As String
        Dim FIndex1, LIndex1, FIndex2, ChkIndex1a, ChkIndex2a, ChkIndex1b, ChkIndex2b As Integer
        Dim ChkIndex1, ChkIndex2, Mfxfld0to5, MFixFld18to21, MFixFld18_21, M00818t21, M008FixFld18to21, M200a, Mfxfld200a, Mfxfld200b As String

        'PictureBox1.Visible = True
        'First 24 Charecter Leader
        ' 00-04 - Record length d
        ' 05 - Record status d
        ' 06 - Type of record
        ' 07 - Bibliographic level
        ' 08 - Type of control 
        ' 09 - Character coding scheme
        ' 10 - Indicator count
        ' 11 - Subfield code count
        ' 12-16 - Base address of data
        ' 17 - Encoding level
        ' 18 - Descriptive cataloging form
        ' 19 - Linked record requirement
        ' 20-23 - Entry map

        GetMarcRecId()
        M000 = "00000cam a2200000ua 4500"
        FillBibRecAry(MarcTagSrNo, "000", "", MarcTagSbFldSrNo, "", M000)

        '------------------------------------------------------
        'marc 007 get from CCF 060^a if value is "100" then Marc007="t"
        'Marc008 
        'fixfld'
        '0-5 get from CCF 022^a in format yy/mm/dd
        '6-t
        '07-10 get from CCF 440^a (year)
        '11-14 get value ||||
        '15-17 get value from CCF 400^d if CCF 440^d is not present then Value is "|||"
        '18-21 get  value from check CCF 460^b is presenr then Value is "a|||" else "||||"
        'and Chek index of Illustration,charts,table,index,music etc from site www.loc.gov/marc
        '22=" "
        '23-" "
        '24-27 ????? PENDING::(Theses)
        'here 24-27 check CCF 200^a or ^b check word Dictonary,encyclopidia,handbook then put word d,e,f,etc as follow site www.loc.gov/marc
        '28- check if CCF 310^a is present then value "0" else " "
        '29- check if CCF 320^a is present then value "1" else "0"
        '30- get from CCF 200^a check word Festchrift then "1" else"0"
        '31-check CCF 200^a or CCF 200^b if "index"or "Index" is in CCF 200^a then vale is "1" else"0"
        '32-" "
        '33-"|"
        '34-"|"
        '35-37 get from CCF 040^a 
        '38 is Blank
        '39 is "C"
        GETTagVal(CCFTable, "060", "^a", RetCCFVal)
        M007 = RetCCFVal(0)
        If M007 = "100" Then
            M007 = "t"
            FillBibRecAry(MarcTagSrNo, "007", "  ", MarcTagSbFldSrNo, "", M007)
        Else
            M007 = " "
            FillBibRecAry(MarcTagSrNo, "007", "  ", MarcTagSbFldSrNo, "", M007)
        End If

        'Marc 008
        '0-5 get from CCF 022^a in format yy/mm/dd
        GETTagVal(CCFTable, "022", "^a", RetCCFVal)
        Mfxfld00to05 = RetCCFVal(0)
        If Mfxfld00to05 <> "Tag Not Available" Then
            GetMfxfld00to05(Mfxfld00to05, Mfxfld0to5) 'this function get date From CCF022^a in YYMMDD format
            MFixFLd00to05 = Mfxfld0to5
        Else
            '0-5 get from CCF 023^a in format yy/mm/dd
            GETTagVal(CCFTable, "023", "^a", RetCCFVal)
            Mfxfld00to05 = RetCCFVal(0)
            GetMfxfld00to05(Mfxfld00to05, Mfxfld0to5)
            MFixFLd00to05 = Mfxfld0to5
        End If

        '6-tMfxfld06 = "t"
        Mfxfld06 = "t"
        '07-10 get from CCF 440^a (year)
        GETTagVal(CCFTable, "440", "^a", RetCCFVal)
        Mfxfld7to10 = RetCCFVal(0)
        'GETTagVal(CCFTable, "400", "^e", RetCCFVal)
        'Mfixfld7to10 = RetCCFVal(0)
        If Mfxfld7to10 <> "Tag Not Available" Then
            Mfxfld07to10 = RetCCFVal(0)
        ElseIf Mfixfld7to10 <> "Tag Not Available" Then
            Mfixfld07to10 = RetCCFVal(0)
        Else
            Mfxfld07to10 = "    "
            Mfixfld07to10 = "    "
        End If
        '11-14 get value ||||
        Mfxfld11to14 = "||||"
        '15-17 get value from CCF 400^d if CCF 440^d is not present then Value is "|||"
        GETTagVal(CCFTable, "400", "^d", RetCCFVal)
        Mfxfld15to17 = RetCCFVal(0)
        If Mfxfld15to17 <> "Tag Not Available" Then
            Mfxfld15to17 = RetCCFVal(0)
        Else
            Mfxfld15to17 = "|||"
        End If
        '18-21 get  value from check CCF 460^b is presenr then Value is "a|||" else "||||"
        '18-21 get  value from check CCF 460^b is presenr then Value is "a|||" else "||||"
        'and Chek index of Illustration,charts,table,index,music etc from site www.loc.gov/marc
        GETTagVal(CCFTable, "460", "^b", RetCCFVal)
        Mfxfld18to21 = RetCCFVal(0)
        If (Mfxfld18to21.IndexOf("ill")) <> -1 Then
            '(Mfxfld18to21.IndexOf("illustration") <> -1) Then
            MFixFld18_21 = "ill"
            GetMfxfld18t21(M00818t21, MFixFld18_21)
        End If
        If (Mfxfld18to21.IndexOf("map")) <> -1 Then
            MFixFld18_21 = "map"
            GetMfxfld18t21(M00818t21, MFixFld18_21)
        End If
        If (Mfxfld18to21.IndexOf("chart")) <> -1 Then
            MFixFld18_21 = "chart"
            GetMfxfld18t21(M00818t21, MFixFld18_21)
        End If
        If (Mfxfld18to21.IndexOf("plan")) <> -1 Then
            MFixFld18_21 = "plan"
            GetMfxfld18t21(M00818t21, MFixFld18_21)
        End If
        If (Mfxfld18to21.IndexOf("plate")) <> -1 Then
            MFixFld18_21 = "plate"
            GetMfxfld18t21(M00818t21, MFixFld18_21)
        End If
        If (Mfxfld18to21.IndexOf("music")) <> -1 Then
            MFixFld18_21 = "music"
            GetMfxfld18t21(M00818t21, MFixFld18_21)
        End If
        If (Mfxfld18to21.IndexOf("facsimile")) <> -1 Then
            MFixFld18_21 = "facsimile"
            GetMfxfld18t21(M00818t21, MFixFld18_21)
        End If
        If (Mfxfld18to21.IndexOf("table")) <> -1 Then
            MFixFld18_21 = "table"
            GetMfxfld18t21(M00818t21, MFixFld18_21)
        End If
        If (Mfxfld18to21.IndexOf("table")) = -1 And (Mfxfld18to21.IndexOf("facsimile")) = -1 And (Mfxfld18to21.IndexOf("music")) = -1 And (Mfxfld18to21.IndexOf("plate")) = -1 And (Mfxfld18to21.IndexOf("plan")) = -1 And (Mfxfld18to21.IndexOf("chart")) = -1 And (Mfxfld18to21.IndexOf("ill")) = -1 Then
            MFixFld18_21 = "||||"
            GetMfxfld18t21(M00818t21, MFixFld18_21)
        End If
        'M008FixFld18to21 = M00818t21
        If M00818t21.Length = 4 Then
            M008FixFld18to21 = M00818t21
        ElseIf M00818t21.Length = 3 Then
            M008FixFld18to21 = M00818t21.Substring(0, 3) & "|"
        ElseIf M00818t21.Length = 2 Then
            M008FixFld18to21 = M00818t21.Substring(0, 2) & "|" & "|"
        ElseIf M00818t21.Length = 1 Then
            M008FixFld18to21 = M00818t21.Substring(0, 1) & "|" & "|" & "|"
        ElseIf M00818t21.Length > 4 Then
            M008FixFld18to21 = M00818t21.Substring(0, 4)
        End If

        '22=" "
        Mfxfld22 = " "
        '23-" "
        Mfxfld23 = " "
        '24-27 ????? PENDING::(Theses)
        'here 24-27 check CCF 200^a or ^b check word Dictonary,encyclopidia,handbook then put word d,e,f,etc as follow site www.loc.gov/marc
        Mfxfld24to27 = "    "
        '28- check if CCF 310^a is present then value "0" else " "
        GETTagVal(CCFTable, "310", "^a", RetCCFVal)
        Mfxfld28 = RetCCFVal(0)
        If Mfxfld28 <> "Tag Not Available" Then
            Mfxfld28 = "0"
        Else
            Mfxfld28 = " "
        End If
        '29- check if CCF 320^a is present then value "1" else "0"
        GETTagVal(CCFTable, "320", "^a", RetCCFVal)
        Mfxfld29 = RetCCFVal(0)
        If Mfxfld29 <> "Tag Not Available" Then
            Mfxfld29 = "1"
        Else
            Mfxfld29 = "0"
        End If
        '30- "|"
        'Mfxfld30 = "|"
        '30- get from CCF 200^a check word Festchrift then "1" else"0"
        GETTagVal(CCFTable, "200", "^a", RetCCFVal)
        Mfxfld200a = RetCCFVal(0)
        If (Mfxfld200a.IndexOf("Festschrift") = -1) And (Mfxfld200a.IndexOf("Festschrift") = -1) And (Mfxfld200a.IndexOf("Felicitation") = -1) And (Mfxfld200a.IndexOf("Felicitation") = -1) Then
            Mfxfld30 = "0"
        Else
            Mfxfld30 = "1"
        End If


        '31-check CCF 500^a if "index"or "Index" is in CCF 500^a then vale is "1" else"0"  ??Pending::
        GETTagVal(CCFTable, "500", "^a", RetCCFVal)
        M500a = RetCCFVal(0)
        ChkIndex1 = "Index"
        ChkIndex2 = "index"
        FIndex1 = M500a.IndexOf(ChkIndex1)
        FIndex2 = M500a.IndexOf(ChkIndex2)
        If M500a <> "Tag Not Available" Then
            If FIndex1 = -1 And FIndex2 = -1 Then
                Mfxfld31 = "0"
            Else
                Mfxfld31 = "1"
            End If
        End If

        '32-" "
        Mfxfld32 = " "
        '33-"|"
        Mfxfld33 = "|"
        '34-"|"
        Mfxfld34 = "|"
        '35-37 get from CCF 040^a 
        GETTagVal(CCFTable, "040", "^a", RetCCFVal)
        Mfxfl035to37 = RetCCFVal(0)
        If Mfxfl035to37 <> "Tag Not Available" Then
            Mfxfl35to37 = RetCCFVal(0)
        Else
            Mfxfl35to37 = "|||"
        End If
        '38 is Blank
        Mfxfld38 = " "
        '39 is "C"
        Mfxfld39 = "c"

        GETTagVal(CCFTable, "440", "^a", RetCCFVal)
        Mfxfld7to10 = RetCCFVal(0)
        'GETTagVal(CCFTable, "400", "^e", RetCCFVal)
        'Mfixfld7to10 = RetCCFVal(0)
        If Mfxfld7to10 <> "Tag Not Available" Then
            If Mfxfld7to10.Length = 8 Then
                M008 = MFixFLd00to05 & Mfxfld06 & Mfxfld07to10 & Mfxfld15to17 & M008FixFld18to21 & Mfxfld22 & Mfxfld23 & Mfxfld24to27 & Mfxfld28 & Mfxfld29 & Mfxfld30 & Mfxfld31 & Mfxfld32 & Mfxfld33 & Mfxfld34 & Mfxfl35to37 & Mfxfld38 & Mfxfld39
                FillBibRecAry(MarcTagSrNo, "008", "  ", MarcTagSbFldSrNo, "", M008)
            Else
                M008 = MFixFLd00to05 & Mfxfld06 & Mfxfld07to10 & Mfxfld11to14 & Mfxfld15to17 & M008FixFld18to21 & Mfxfld22 & Mfxfld23 & Mfxfld24to27 & Mfxfld28 & Mfxfld29 & Mfxfld30 & Mfxfld31 & Mfxfld32 & Mfxfld33 & Mfxfld34 & Mfxfl35to37 & Mfxfld38 & Mfxfld39
                FillBibRecAry(MarcTagSrNo, "008", "  ", MarcTagSbFldSrNo, "", M008)
            End If
            'ElseIf Mfixfld7to10 <> "Tag Not Available" Then
            '    If Mfixfld7to10.Length = 8 Then
            '        M008 = MFixFLd00to05 & Mfxfld06 & Mfixfld7to10 & Mfxfld15to17 & Mfxfld18to21 & Mfxfld22 & Mfxfld23 & Mfxfld24to27 & Mfxfld28 & Mfxfld29 & Mfxfld30 & Mfxfld31 & Mfxfld32 & Mfxfld33 & Mfxfld34 & Mfxfl35to37 & Mfxfld38 & Mfxfld39
            '        FillBibRecAry(MarcTagSrNo, "008", "  ", MarcTagSbFldSrNo, "", M008)
            '    Else
            '        M008 = MFixFLd00to05 & Mfxfld06 & Mfixfld7to10 & Mfxfld11to14 & Mfxfld15to17 & Mfxfld18to21 & Mfxfld22 & Mfxfld23 & Mfxfld24to27 & Mfxfld28 & Mfxfld29 & Mfxfld30 & Mfxfld31 & Mfxfld32 & Mfxfld33 & Mfxfld34 & Mfxfl35to37 & Mfxfld38 & Mfxfld39
            '        FillBibRecAry(MarcTagSrNo, "008", "  ", MarcTagSbFldSrNo, "", M008)
            '    End If
        Else
            M008 = MFixFLd00to05 & Mfxfld06 & Mfxfld07to10 & Mfxfld11to14 & Mfxfld15to17 & M008FixFld18to21 & Mfxfld22 & Mfxfld23 & Mfxfld24to27 & Mfxfld28 & Mfxfld29 & Mfxfld30 & Mfxfld31 & Mfxfld32 & Mfxfld33 & Mfxfld34 & Mfxfl35to37 & Mfxfld38 & Mfxfld39
            FillBibRecAry(MarcTagSrNo, "008", "  ", MarcTagSbFldSrNo, "", M008)
            'M008 = MFixFLd00to05 & Mfxfld06 & Mfixfld07to10 & Mfxfld11to14 & Mfxfld15to17 & Mfxfld18to21 & Mfxfld22 & Mfxfld23 & Mfxfld24to27 & Mfxfld28 & Mfxfld29 & Mfxfld30 & Mfxfld31 & Mfxfld32 & Mfxfld33 & Mfxfld34 & Mfxfl35to37 & Mfxfld38 & Mfxfld39
            'FillBibRecAry(MarcTagSrNo, "008", "  ", MarcTagSbFldSrNo, "", M008)
        End If
        '------------------------------------------------------
        'Marc 016$a get from CCF 110^a 
        GETTagVal(CCFTable, "110", "^a", RetCCFVal)
        M016 = RetCCFVal(0)
        If M016 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "110", "^a", RetCCFVal)
                M016 = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "016", "  ", MarcTagSbFldSrNo, "a", M016)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        ''Marc 020$c get from CCF 100^a
        GETTagVal(CCFTable, "100", "^a", RetCCFVal)
        M020a = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M020a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "100", "^a", RetCCFVal)
                M020a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "020", "  ", MarcTagSbFldSrNo, "a", M020a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If
        'Marc 020$c get from CCF 100^c
        GETTagVal(CCFTable, "100", "^c", RetCCFVal)
        M020c = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M020c <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "100", "^c", RetCCFVal)
                M020c = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "020", "  ", MarcTagSbFldSrNo, "c", M020c)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        Else
            'Mrac 020$c get from CCF 465^a
            GETTagVal(CCFTable, "465", "^a", RetCCFVal)
            M020c = RetCCFVal(0)
            If M020c <> "Tag Not Available" Then
                ArrLength = ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    GETTagVal(CCFTable, "465", "^a", RetCCFVal)
                    M020c = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "020", "  ", MarcTagSbFldSrNo, "c", M020c)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
        End If
        'Marc 020$z get from CCF 100^b
        GETTagVal(CCFTable, "100", "^b", RetCCFVal)
        M020z = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M020z <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "100", "^b", RetCCFVal)
                M020z = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "020", "  ", MarcTagSbFldSrNo, "z", M020z)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If
        'Marc 022$a get from CCF 101^a    
        GETTagVal(CCFTable, "101", "^a", RetCCFVal)
        M022a = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M022a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "101", "^a", RetCCFVal)
                M022a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "022", "  ", MarcTagSbFldSrNo, "a", M022a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 022$y get from CCF 101^b  
        GETTagVal(CCFTable, "101", "^b", RetCCFVal)
        M022y = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M022y <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "101", "^b", RetCCFVal)
                M022y = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "020", "  ", MarcTagSbFldSrNo, "y", M022y)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 022$z get from CCF 101^c
        GETTagVal(CCFTable, "101", "^c", RetCCFVal)
        M022z = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M022z <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "101", "^c", RetCCFVal)
                M022z = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "020", "  ", MarcTagSbFldSrNo, "z", M022z)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 027 get from CCF 120^a
        GETTagVal(CCFTable, "120", "^a", RetCCFVal)
        M027 = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M027 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "120", "^a", RetCCFVal)
                M027 = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "027", "  ", MarcTagSbFldSrNo, "a", M027)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'marc 030 get from CCF 102^a
        GETTagVal(CCFTable, "102", "^a", RetCCFVal)
        M030 = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M030 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "102", "^a", RetCCFVal)
                M030 = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "030", "  ", MarcTagSbFldSrNo, "a", M030)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Tag 40.. with subfields a e and b
        'Marc 040$a get from CCF 020^b
        GETTagVal(CCFTable, "020", "^b", RetCCFVal)
        M040a = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M040a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "020", "^b", RetCCFVal)
                M040a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "040", "  ", MarcTagSbFldSrNo, "a", M040a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 040$e get from CCF 020^d
        GETTagVal(CCFTable, "020", "^d", RetCCFVal)
        M040e = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M040e <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "020", "^d", RetCCFVal)
                M040e = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "040", "  ", MarcTagSbFldSrNo, "e", M040e)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 040$b get from CCF 020^l
        GETTagVal(CCFTable, "020", "^l", RetCCFVal)
        M040b = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M040b <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "020", "^l", RetCCFVal)
                M040b = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "040", "  ", MarcTagSbFldSrNo, "b", M040b)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If
        'Marc 041$a get from CCF 040^a
        GETTagVal(CCFTable, "040", "^a", RetCCFVal)
        M041a = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M041a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "040", "^a", RetCCFVal)
                M041a = RetCCFVal(0)
                FillBibRecAry(MarcTagSrNo, "041", "0 ", MarcTagSbFldSrNo, "a", M041a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 044$a get from CCF 400^d
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "400", "^d", RetCCFVal)
        M044a = RetCCFVal(0)
        If M044a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "400", "^d", RetCCFVal)
                M044a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "044", "  ", MarcTagSbFldSrNo, "a", M044a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        '------------------------------
        'Marc 050$a get from CCF 610^c l
        ' if here Clasification Sceame is present then Classification Sceame is U or D or L 'if CCF 610^c Have Clssifi. Sceame is L then
        GETTagVal(CCFTable, "610", "^c", RetCCFVal)
        MClaS = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If MClaS <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                '(First Occurance...) 
                GETTagVal(CCFTable, "610", "^c", RetCCFVal)
                MClaS = RetCCFVal(ArrayCount)
                If Asc(MClaS.Chars(0)) = 85 Or Asc(MClaS.Chars(0)) = 117 Then
                    'Marc M080 FI=SI=Blank $a get from CCF 610^a
                    GETTagVal(CCFTable, "610", "^a", RetCCFVal)
                    M080 = RetCCFVal(ArrayCount)
                    If M080 <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "080", "  ", MarcTagSbFldSrNo, "a", M080)
                    End If
                    'Marc M080 FI=SI=Blank $b get from CCF 610^d
                    GETTagVal(CCFTable, "610", "^d", RetCCFVal)
                    M080b = RetCCFVal(ArrayCount)
                    If M080b <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "080", "  ", MarcTagSbFldSrNo, "a", M080b)
                    End If

                ElseIf Asc(MClaS.Chars(0)) = 68 Or Asc(MClaS.Chars(0)) = 100 Then
                    'Marc 082 FI=SI=blank $a get from CCF 610^a
                    GETTagVal(CCFTable, "610", "^a", RetCCFVal)
                    M082 = RetCCFVal(ArrayCount)
                    If M082 <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "082", "1 ", MarcTagSbFldSrNo, "a", M082)
                    End If
                    'Marc 082 FI=Si=Blank $b get from CCF 610^d
                    GETTagVal(CCFTable, "610", "^d", RetCCFVal)
                    M082b = RetCCFVal(ArrayCount)
                    If M082b <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "082", "  ", MarcTagSbFldSrNo, "b", M082b)
                    End If

                ElseIf Asc(MClaS.Chars(0)) = 76 Or Asc(MClaS.Chars(0)) = 108 Then
                    'Marc 050  FI=Si=Blank$a get from CCF 610^a
                    GETTagVal(CCFTable, "610", "^a", RetCCFVal)
                    M050a = RetCCFVal(ArrayCount)
                    If M050a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "050", "1 ", MarcTagSbFldSrNo, "a", M050a)
                    End If
                    'Marc 050 FI=Si=Blank $a get from CCF 610^d
                    GETTagVal(CCFTable, "610", "^d", RetCCFVal)
                    M050b = RetCCFVal(ArrayCount)
                    If M050b <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "050", "  ", MarcTagSbFldSrNo, "b", M050b)
                    End If
                Else
                    GETTagVal(CCFTable, "610", "^a", RetCCFVal)
                    M084 = RetCCFVal(ArrayCount)
                    If M084 <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "084", "  ", MarcTagSbFldSrNo, "a", M084)
                    End If
                    'Marc 084  FI=Si=Blank $a get from CCF 610^d
                    GETTagVal(CCFTable, "610", "^d", RetCCFVal)
                    M084b = RetCCFVal(ArrayCount)
                    If M084b <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "084", "  ", MarcTagSbFldSrNo, "b", M084b)
                    End If
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        Else 'if CCF610^c is not available
            'Marc 084  FI=Si=Blank$a get from CCF 610^a
            GETTagVal(CCFTable, "610", "^a", RetCCFVal)
            M084 = RetCCFVal(0)
            If M084 <> "Tag Not Available" Then
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    GETTagVal(CCFTable, "610", "^a", RetCCFVal)
                    M084 = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "084", "  ", MarcTagSbFldSrNo, "a", M084)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
            'Marc 084  FI=Si=Blank $a get from CCF 610^d  ????? PENDING::::
            GETTagVal(CCFTable, "610", "^d", RetCCFVal)
            M084b = RetCCFVal(0)
            If M084b <> "Tag Not Available" Then
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    If ArrayCount = 0 Then
                        GETTagVal(CCFTable, "610", "^d", RetCCFVal)
                        M084b = RetCCFVal(ArrayCount)
                        FillBibRecAry(MarcTagSrNo, "084", "  ", MarcTagSbFldSrNo, "b", M084b)
                        MarcTagSrNo += 1
                        MarcTagSbFldSrNo += 1
                    End If
                Next
            End If
        End If
        'Marc 088$a get From CCF 125^a 
        GETTagVal(CCFTable, "125", "^a", RetCCFVal)
        M088a = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M088a <> "Tag Not Available" Then
            ArrLength = ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                '(First Occurance...)
                GETTagVal(CCFTable, "125", "^a", RetCCFVal)
                M088a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "088", "  ", MarcTagSbFldSrNo, "a", M088a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1

            Next
        End If

        'Marc 090   get from CCF 610^b          
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "610", "^b", RetCCFVal)
        M090 = RetCCFVal(0)
        If M090 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "610", "^b", RetCCFVal)
                M090 = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "090", "  ", MarcTagSbFldSrNo, "a", M090)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        ' ------------------------------------------------------------------------------------------------------

        'Marc 100$a get from CCF 300^a here if Check ^b first occurance is avil lable then    ????? PENDINIG::::
        GETTagVal(CCFTable, "300", "^b", RetCCFVal)
        M100 = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M100 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    GETTagVal(CCFTable, "300", "^f", RetCCFVal)
                    M100f = RetCCFVal(0)
                    Dim Arrlen As Integer
                    Arrlen = RetCCFVal.Length
                    If Arrlen = ArrLength Then
                        If M100f <> "Tag Not Available" Then
                            If (M100f.Length >= 6) Then
                                'If ((Asc(M100f.Chars(0)) = 97 Or Asc(M100f.Chars(0)) = 65) And (Asc(M100f.Chars(1)) = 117 Or Asc(M100f.Chars(1)) = 85) And (Asc(M100f.Chars(2)) = 116 Or Asc(M100f.Chars(2)) = 84) And (Asc(M100f.Chars(3)) = 104 Or Asc(M100f.Chars(3)) = 72) And (Asc(M100f.Chars(4)) = 111 Or Asc(M100f.Chars(4)) = 79) And (Asc(M100f.Chars(5)) = 114 Or Asc(M100f.Chars(5)) = 82)) Or M100f = "Tag Not Available" Then
                                If (M100f.Chars(0) = "a" Or M100f.Chars(0) = "A") And (M100f.Chars(1) = "u" Or M100f.Chars(1) = "U") And (M100f.Chars(2) = "t" Or M100f.Chars(2) = "T") And (M100f.Chars(3) = "h" Or M100f.Chars(3) = "H") And (M100f.Chars(4) = "o" Or M100f.Chars(4) = "O") And (M100f.Chars(5) = "r" Or M100f.Chars(5) = "R") Then
                                    GETTagVal(CCFTable, "300", "^b", RetCCFVal)
                                    M100 = RetCCFVal(ArrayCount)
                                    GETTagVal(CCFTable, "300", "^a", RetCCFVal)
                                    M100a = RetCCFVal(ArrayCount)
                                    M100ab = M100a & "," & " " & M100
                                    FillBibRecAry(MarcTagSrNo, "100", "0 ", MarcTagSbFldSrNo, "a", M100ab)
                                End If
                            End If
                        Else
                            GETTagVal(CCFTable, "300", "^b", RetCCFVal)
                            M700 = RetCCFVal(ArrayCount)
                            GETTagVal(CCFTable, "300", "^a", RetCCFVal)
                            M700a = RetCCFVal(ArrayCount)
                            M700ab = M700a & "," & " " & M700
                            FillBibRecAry(MarcTagSrNo, "700", "02", MarcTagSbFldSrNo, "a", M700ab)
                            MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                            MarcTagSrNo = MarcTagSrNo + 1
                        End If
                    Else
                        ArrLength = 1
                        GETTagVal(CCFTable, "300", "^b", RetCCFVal)
                        M100 = RetCCFVal(ArrayCount)
                        GETTagVal(CCFTable, "300", "^a", RetCCFVal)
                        M100a = RetCCFVal(ArrayCount)
                        M100ab = M100a & "," & " " & M100
                        FillBibRecAry(MarcTagSrNo, "100", "0 ", MarcTagSbFldSrNo, "a", M100ab)
                    End If

                Else '(Second.third occurance)                   
                    GETTagVal(CCFTable, "300", "^b", RetCCFVal)
                    '////////Temp change here
                    'Try
                    M700 = RetCCFVal(ArrayCount)
                    GETTagVal(CCFTable, "300", "^a", RetCCFVal)
                    M700a = RetCCFVal(ArrayCount)
                    M700ab = M700a & "," & " " & M700
                    FillBibRecAry(MarcTagSrNo, "700", "02", MarcTagSbFldSrNo, "a", M700ab)
                    'Catch
                    'End Try
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                End If
            Next

        Else 'if CCF 300^b is not present
            GETTagVal(CCFTable, "300", "^a", RetCCFVal)
            M100a = RetCCFVal(0)
            If M100a <> "Tag Not Available" Then
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    If ArrayCount = 0 Then
                        GETTagVal(CCFTable, "300", "^f", RetCCFVal)
                        M100f = RetCCFVal(0)
                        Dim Arrlen As Integer
                        Arrlen = RetCCFVal.Length
                        If Arrlen = ArrLength Then
                            If M100f <> "Tag Not Available" Then
                                If (M100f.Length >= 6) Then
                                    'If ((Asc(M100f.Chars(0)) = 97 Or Asc(M100f.Chars(0)) = 65) And (Asc(M100f.Chars(1)) = 117 Or Asc(M100f.Chars(1)) = 85) And (Asc(M100f.Chars(2)) = 116 Or Asc(M100f.Chars(2)) = 84) And (Asc(M100f.Chars(3)) = 104 Or Asc(M100f.Chars(3)) = 72) And (Asc(M100f.Chars(4)) = 111 Or Asc(M100f.Chars(4)) = 79) And (Asc(M100f.Chars(5)) = 114 Or Asc(M100f.Chars(5)) = 82)) Or M100f = "Tag Not Available" Then
                                    If (M100f.Chars(0) = "a" Or M100f.Chars(0) = "A") And (M100f.Chars(1) = "u" Or M100f.Chars(1) = "U") And (M100f.Chars(2) = "t" Or M100f.Chars(2) = "T") And (M100f.Chars(3) = "h" Or M100f.Chars(3) = "H") And (M100f.Chars(4) = "o" Or M100f.Chars(4) = "O") And (M100f.Chars(5) = "r" Or M100f.Chars(5) = "R") Then
                                        GETTagVal(CCFTable, "300", "^b", RetCCFVal)
                                        M100 = RetCCFVal(ArrayCount)
                                        GETTagVal(CCFTable, "300", "^a", RetCCFVal)
                                        M100a = RetCCFVal(ArrayCount)
                                        M100ab = M100a & "," & " " & M100
                                        FillBibRecAry(MarcTagSrNo, "100", "0 ", MarcTagSbFldSrNo, "a", M100ab)
                                    End If
                                End If
                            Else
                                GETTagVal(CCFTable, "300", "^b", RetCCFVal)
                                M700 = RetCCFVal(ArrayCount)
                                GETTagVal(CCFTable, "300", "^a", RetCCFVal)
                                M700a = RetCCFVal(ArrayCount)
                                M700ab = M700a & "," & " " & M700
                                FillBibRecAry(MarcTagSrNo, "700", "02", MarcTagSbFldSrNo, "a", M700ab)
                                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                                MarcTagSrNo = MarcTagSrNo + 1
                            End If
                        Else
                            ArrLength = 1
                            GETTagVal(CCFTable, "300", "^b", RetCCFVal)
                            M100 = RetCCFVal(ArrayCount)
                            GETTagVal(CCFTable, "300", "^a", RetCCFVal)
                            M100a = RetCCFVal(ArrayCount)
                            M100ab = M100a & "," & " " & M100
                            FillBibRecAry(MarcTagSrNo, "100", "0 ", MarcTagSbFldSrNo, "a", M100ab)
                        End If
                    Else 'Second Occurance 
                        GETTagVal(CCFTable, "300", "^a", RetCCFVal)
                        M700a = RetCCFVal(ArrayCount) & " "
                        FillBibRecAry(MarcTagSrNo, "700", "02", MarcTagSbFldSrNo, "a", M700a)
                        MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                        MarcTagSrNo = MarcTagSrNo + 1
                    End If
                Next
            End If
        End If

        '----------------------------------------
        'Marc 700,Second Indicatar get from CCF 300,Second or Third Occurance
        '---------------------------------------------

        'if here Marc 110 Indicatar First 0 get from CCF 310(First Occurance)              
        'Marc 110$a get from  CCF 310^a 
        GETTagVal(CCFTable, "310", "^a", RetCCFVal)
        M110a = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M110a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    GETTagVal(CCFTable, "310", "^a", RetCCFVal)
                    M110a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "110", "0 ", MarcTagSbFldSrNo, "a", RetCCFVal(ArrayCount))
                Else
                    'Marc 710$a get value from CCF 310^a (Second or third occuu......)
                    GETTagVal(CCFTable, "310", "^a", RetCCFVal)
                    M710a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "710", "02", MarcTagSbFldSrNo, "a", RetCCFVal(ArrayCount))
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                End If
            Next
        End If
        'Marc 110$b get from  CCF 310^b
        GETTagVal(CCFTable, "310", "^b", RetCCFVal)
        M110b = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M110b <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    'Marc 710$b get value from CCF 310^b(firstOccurance....)
                    GETTagVal(CCFTable, "310", "^b", RetCCFVal)
                    M110b = RetCCFVal(ArrayCount)
                    If M110b <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "110", "0 ", MarcTagSbFldSrNo, "b", RetCCFVal(ArrayCount))
                    End If
                Else
                    'Marc 710$b get value from CCF 310^b (Second or third occuu......)
                    GETTagVal(CCFTable, "310", "^b", RetCCFVal)
                    M710b = RetCCFVal(ArrayCount)
                    If M710b <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "710", "02", MarcTagSbFldSrNo, "b", RetCCFVal(ArrayCount))
                    End If
                    MarcTagSrNo += 1
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                End If
            Next
        End If
        'marc 110$c get from  CCF 310^c
        GETTagVal(CCFTable, "310", "^c", RetCCFVal)
        M110c = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M110c <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    'marc 110$c get from  CCF 310^c(firstOccurance....)
                    GETTagVal(CCFTable, "310", "^c", RetCCFVal)
                    M110c = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "110", "0 ", MarcTagSbFldSrNo, "c", RetCCFVal(ArrayCount))
                Else
                    'Marc 710$c get value from CCF 310^c (Second or third occuu......)
                    GETTagVal(CCFTable, "310", "^c", RetCCFVal)
                    M710c = RetCCFVal(ArrayCount)
                    If M710c <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "710", "02", MarcTagSbFldSrNo, "c", RetCCFVal(ArrayCount))
                    End If
                    MarcTagSrNo += 1
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                End If
            Next
        End If
        'Marc 110$l Get from  CCF 310^l 
        GETTagVal(CCFTable, "310", "^l", RetCCFVal)
        M110l = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M110l <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    'Marc 110$l Get from  CCF 310^l (firstOccurance....)
                    GETTagVal(CCFTable, "310", "^c", RetCCFVal)
                    M110l = RetCCFVal(ArrayCount)
                    If M110l <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "110", "0 ", MarcTagSbFldSrNo, "l", RetCCFVal(ArrayCount))
                    End If
                Else
                    'Marc 710$l get value from CCF 310^l (Second or third occuu......)
                    GETTagVal(CCFTable, "310", "^c", RetCCFVal)
                    M710l = RetCCFVal(ArrayCount)
                    If M710l <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "710", "02", MarcTagSbFldSrNo, "l", RetCCFVal(ArrayCount))
                    End If
                    MarcTagSrNo += 1
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                End If
            Next
        End If

        '----------------------------------------------------------------------------------------------------------

        'Marc 111$a get from CCF 320^a
        GETTagVal(CCFTable, "320", "^a", RetCCFVal)
        M111a = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M111a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    GETTagVal(CCFTable, "320", "^a", RetCCFVal)
                    M111a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "111", "1 ", MarcTagSbFldSrNo, "a", M111a)
                Else
                    GETTagVal(CCFTable, "320", "^a", RetCCFVal)
                    M711a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "711", "12", MarcTagSbFldSrNo, "a", M711a)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                End If
            Next
        End If

        'Marc 111$e get from CCF 320^b
        GETTagVal(CCFTable, "320", "^b", RetCCFVal)
        M111e = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M111e <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    GETTagVal(CCFTable, "320", "^b", RetCCFVal)
                    M111e = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "111", "1 ", MarcTagSbFldSrNo, "e", M111e)
                Else
                    GETTagVal(CCFTable, "320", "^b", RetCCFVal)
                    M711e = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "711", "12", MarcTagSbFldSrNo, "e", M711e)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                End If
            Next
        End If

        'Marc 111$c get from CCF 320^g
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "320", "^g", RetCCFVal)
        M111c = RetCCFVal(0)
        If M111c <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    GETTagVal(CCFTable, "320", "^g", RetCCFVal)
                    M111c = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "111", "1 ", MarcTagSbFldSrNo, "c", M111c)
                Else
                    GETTagVal(CCFTable, "320", "^g", RetCCFVal)
                    M711c = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "711", "12", MarcTagSbFldSrNo, "c", M711c)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                End If
            Next
        End If

        'Marc 111$d get from CCF 320^h
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "320", "^h", RetCCFVal)
        M111d = RetCCFVal(0)
        If M111d <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    GETTagVal(CCFTable, "320", "^h", RetCCFVal)
                    M111d = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "111", "1 ", MarcTagSbFldSrNo, "d", M111d)
                Else
                    GETTagVal(CCFTable, "320", "^h", RetCCFVal)
                    M711d = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "711", "12", MarcTagSbFldSrNo, "d", M711d)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                End If
            Next
        End If

        'Marc 130$a get from CCF 240^a 
        '???-----------------------------------------------------------------------------------------------------------
        GETTagVal(CCFTable, "240", "^a", RetCCFVal)
        M130 = RetCCFVal(0)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        If M130 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                '(if First occurance)
                If ArrayCount = 0 Then
                    GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                    MChkFISbFildsVal = RetCCFVal(ArrayCount)
                    If MChkFISbFildsVal <> "Tag Not Available" Then
                        'Marc 130 First Indicator 3 get from CCF 240^a ''if First Check CCF Tag =240 then Check Subfields a 's First Bigining 'an' there fore(if First occurance)
                        If MChkFISbFildsVal.Length >= 1 Then
                            If MChkFISbFildsVal.Chars(0) = "A" Or MChkFISbFildsVal.Chars(0) = "a" Then
                                strbool = True
                                GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                M130FI2 = RetCCFVal(ArrayCount)
                            Else
                                strbool = False
                            End If
                            If strbool = True Then
                                If MChkFISbFildsVal.Length >= 2 Then
                                    If MChkFISbFildsVal.Chars(1) = "N" Or MChkFISbFildsVal.Chars(1) = "n" Then
                                        GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                        M130FI3 = RetCCFVal(ArrayCount)
                                        FillBibRecAry(MarcTagSrNo, "130", "3 ", MarcTagSbFldSrNo, "a", M130FI3)
                                        'Marc 130$n get from CCF 240^b (if First occurance)
                                        GETTagVal(CCFTable, "240", "^b", RetCCFVal)
                                        M130n = RetCCFVal(ArrayCount)
                                        If M130n <> "Tag Not Available" Then
                                            FillBibRecAry(MarcTagSrNo, "130", "3 ", MarcTagSbFldSrNo, "n", M130n)
                                        End If

                                        'Marc 130$p get from CCF 240^c (if First occurance)
                                        GETTagVal(CCFTable, "240", "^c", RetCCFVal)
                                        M130p = RetCCFVal(ArrayCount)
                                        If M130p <> "Tag Not Available" Then
                                            FillBibRecAry(MarcTagSrNo, "130", "3 ", MarcTagSbFldSrNo, "p", M130p)
                                        End If

                                        'Marc 130$k get from CCF 240^d (if First occurance)
                                        GETTagVal(CCFTable, "240", "^d", RetCCFVal)
                                        M130k = RetCCFVal(ArrayCount)
                                        If M130k <> "Tag Not Available" Then
                                            FillBibRecAry(MarcTagSrNo, "130", "3 ", MarcTagSbFldSrNo, "k", M130k)
                                        End If

                                        'Marc 130$c get from CCF 240^e (if First occurance)
                                        GETTagVal(CCFTable, "240", "^e", RetCCFVal)
                                        M130c = RetCCFVal(ArrayCount)
                                        If M130c <> "Tag Not Available" Then
                                            FillBibRecAry(MarcTagSrNo, "130", "3 ", MarcTagSbFldSrNo, "c", M130c)
                                        End If

                                        'Marc 130$s get from CCF 240^f (if First occurance)
                                        GETTagVal(CCFTable, "240", "^f", RetCCFVal)
                                        M130s = RetCCFVal(ArrayCount)
                                        If M130s <> "Tag Not Available" Then
                                            FillBibRecAry(MarcTagSrNo, "130", "3 ", MarcTagSbFldSrNo, "s", M130s)
                                        End If
                                    End If
                                End If
                            End If
                            'Marc 130 First Indicator 2 get from CCF 240^a ''if First Check CCF Tag =240 then Check Subfields a 's First Bigining 'a' there fore
                            If MChkFISbFildsVal.Chars(0) = "A" Or MChkFISbFildsVal.Chars(0) = "a" Then
                                strbool = True
                                GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                M130FI2 = RetCCFVal(ArrayCount)
                                FillBibRecAry(MarcTagSrNo, "130", "2 ", MarcTagSbFldSrNo, "a", M130FI2)
                                'Marc 130$n get from CCF 240^b (if First occurance)
                                GETTagVal(CCFTable, "240", "^b", RetCCFVal)
                                M130n = RetCCFVal(ArrayCount)
                                If M130n <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "2 ", MarcTagSbFldSrNo, "n", M130n)
                                End If

                                'Marc 130$p get from CCF 240^c (if First occurance)
                                GETTagVal(CCFTable, "240", "^c", RetCCFVal)
                                M130p = RetCCFVal(ArrayCount)
                                If M130p <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "2 ", MarcTagSbFldSrNo, "p", M130p)
                                End If

                                'Marc 130$k get from CCF 240^d (if First occurance)
                                GETTagVal(CCFTable, "240", "^d", RetCCFVal)
                                M130k = RetCCFVal(ArrayCount)
                                If M130k <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "2 ", MarcTagSbFldSrNo, "k", M130k)
                                End If

                                'Marc 130$c get from CCF 240^e (if First occurance)
                                GETTagVal(CCFTable, "240", "^e", RetCCFVal)
                                M130c = RetCCFVal(ArrayCount)
                                If M130c <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "2 ", MarcTagSbFldSrNo, "c", M130c)
                                End If

                                'Marc 130$s get from CCF 240^f (if First occurance)
                                GETTagVal(CCFTable, "240", "^f", RetCCFVal)
                                M130s = RetCCFVal(ArrayCount)
                                If M130s <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "2", MarcTagSbFldSrNo, "s", M130s)
                                End If
                            End If
                        End If
                        'Marc 130 First Indicator 4 get from CCF 240^a if First Check CCF Tag =240 then Check Subfields a 's First Bigining 'the' there fore
                        If MChkFISbFildsVal.Length >= 3 Then
                            If MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "THE" Or MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "the" Or MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "THe" Or MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "ThE" Or MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                M130FI4 = RetCCFVal(ArrayCount)
                                FillBibRecAry(MarcTagSrNo, "130", "4 ", MarcTagSbFldSrNo, "a", M130FI4)
                                'Marc 130$n get from CCF 240^b (if First occurance)
                                GETTagVal(CCFTable, "240", "^b", RetCCFVal)
                                M130n = RetCCFVal(ArrayCount)
                                If M130n <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "4 ", MarcTagSbFldSrNo, "n", M130n)
                                End If

                                'Marc 130$p get from CCF 240^c (if First occurance)
                                GETTagVal(CCFTable, "240", "^c", RetCCFVal)
                                M130p = RetCCFVal(ArrayCount)
                                If M130p <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "4 ", MarcTagSbFldSrNo, "p", M130p)
                                End If

                                'Marc 130$k get from CCF 240^d (if First occurance)
                                GETTagVal(CCFTable, "240", "^d", RetCCFVal)
                                M130k = RetCCFVal(ArrayCount)
                                If M130k <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "4 ", MarcTagSbFldSrNo, "k", M130k)
                                End If

                                'Marc 130$c get from CCF 240^e (if First occurance)
                                GETTagVal(CCFTable, "240", "^e", RetCCFVal)
                                M130c = RetCCFVal(ArrayCount)
                                If M130c <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "4 ", MarcTagSbFldSrNo, "c", M130c)
                                End If

                                'Marc 130$s get from CCF 240^f (if First occurance)
                                GETTagVal(CCFTable, "240", "^f", RetCCFVal)
                                M130s = RetCCFVal(ArrayCount)
                                If M130s <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "130", "4 ", MarcTagSbFldSrNo, "s", M130s)
                                End If
                            End If
                        End If
                        If M130FI2 Is Nothing And M130FI3 Is Nothing And M130FI4 Is Nothing Then
                            'Marc 130 First Indicator 0 get from CCF 240^a if First Check CCF Tag =240 then Check Subfields a 's First Bigining 'other' there fore
                            GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                            M130FI0 = RetCCFVal(ArrayCount)
                            FillBibRecAry(MarcTagSrNo, "130", "0 ", MarcTagSbFldSrNo, "a", M130FI0)
                            'Marc 130$n get from CCF 240^b (if First occurance)
                            GETTagVal(CCFTable, "240", "^b", RetCCFVal)
                            M130n = RetCCFVal(ArrayCount)
                            If M130n <> "Tag Not Available" Then
                                FillBibRecAry(MarcTagSrNo, "130", "0 ", MarcTagSbFldSrNo, "n", M130n)
                            End If

                            'Marc 130$p get from CCF 240^c (if First occurance)
                            GETTagVal(CCFTable, "240", "^c", RetCCFVal)
                            M130p = RetCCFVal(ArrayCount)
                            If M130p <> "Tag Not Available" Then
                                FillBibRecAry(MarcTagSrNo, "130", "0 ", MarcTagSbFldSrNo, "p", M130p)
                            End If

                            'Marc 130$k get from CCF 240^d (if First occurance)
                            GETTagVal(CCFTable, "240", "^d", RetCCFVal)
                            M130k = RetCCFVal(ArrayCount)
                            If M130k <> "Tag Not Available" Then
                                FillBibRecAry(MarcTagSrNo, "130", "0 ", MarcTagSbFldSrNo, "k", M130k)
                            End If

                            'Marc 130$c get from CCF 240^e (if First occurance)
                            GETTagVal(CCFTable, "240", "^e", RetCCFVal)
                            M130c = RetCCFVal(ArrayCount)
                            If M130c <> "Tag Not Available" Then
                                FillBibRecAry(MarcTagSrNo, "130", "0 ", MarcTagSbFldSrNo, "c", M130c)
                            End If

                            'Marc 130$s get from CCF 240^f (if First occurance)
                            GETTagVal(CCFTable, "240", "^f", RetCCFVal)
                            M130s = RetCCFVal(ArrayCount)
                            If M130s <> "Tag Not Available" Then
                                FillBibRecAry(MarcTagSrNo, "130", "0 ", MarcTagSbFldSrNo, "s", M130s)
                            End If
                        End If

                    Else   'Marc 730$a Get from CCF 240^a (if second or third Occurance )
                        '(if SEcond,Third,occurance)
                        GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                        MChkFISbFildsVal = RetCCFVal(ArrayCount)
                        If MChkFISbFildsVal <> "Tag Not Available" Then
                            'Marc 130 First Indicator 3 get from CCF 240^a ''if First Check CCF Tag =240 then Check Subfields a 's First Bigining 'an' there fore(if First occurance)
                            If MChkFISbFildsVal.Length >= 1 Then
                                If MChkFISbFildsVal.Chars(0) = "A" Or MChkFISbFildsVal.Chars(0) = "a" Then
                                    strbool = True
                                    GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                    M130FI2 = RetCCFVal(ArrayCount)
                                Else
                                    strbool = False
                                End If
                                If strbool = True Then
                                    If MChkFISbFildsVal.Length >= 2 Then
                                        If MChkFISbFildsVal.Chars(1) = "N" Or MChkFISbFildsVal.Chars(1) = "n" Then
                                            GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                            M130FI3 = RetCCFVal(ArrayCount)
                                            FillBibRecAry(MarcTagSrNo, "730", "32", MarcTagSbFldSrNo, "a", M130FI3)
                                            'Marc 130$n get from CCF 240^b (if First occurance)
                                            GETTagVal(CCFTable, "240", "^b", RetCCFVal)
                                            M130n = RetCCFVal(ArrayCount)
                                            If M130n <> "Tag Not Available" Then
                                                FillBibRecAry(MarcTagSrNo, "730", "32", MarcTagSbFldSrNo, "n", M130n)
                                            End If

                                            'Marc 130$p get from CCF 240^c (if First occurance)
                                            GETTagVal(CCFTable, "240", "^c", RetCCFVal)
                                            M130p = RetCCFVal(ArrayCount)
                                            If M130p <> "Tag Not Available" Then
                                                FillBibRecAry(MarcTagSrNo, "730", "32", MarcTagSbFldSrNo, "p", M130p)
                                            End If

                                            'Marc 130$k get from CCF 240^d (if First occurance)
                                            GETTagVal(CCFTable, "240", "^d", RetCCFVal)
                                            M130k = RetCCFVal(ArrayCount)
                                            If M130k <> "Tag Not Available" Then
                                                FillBibRecAry(MarcTagSrNo, "730", "32", MarcTagSbFldSrNo, "k", M130k)
                                            End If

                                            'Marc 130$c get from CCF 240^e (if First occurance)
                                            GETTagVal(CCFTable, "240", "^e", RetCCFVal)
                                            M130c = RetCCFVal(ArrayCount)
                                            If M130c <> "Tag Not Available" Then
                                                FillBibRecAry(MarcTagSrNo, "730", "32", MarcTagSbFldSrNo, "c", M130c)
                                            End If

                                            'Marc 130$s get from CCF 240^f (if First occurance)
                                            GETTagVal(CCFTable, "240", "^f", RetCCFVal)
                                            M130s = RetCCFVal(ArrayCount)
                                            If M130s <> "Tag Not Available" Then
                                                FillBibRecAry(MarcTagSrNo, "730", "32", MarcTagSbFldSrNo, "s", M130s)
                                            End If
                                        End If
                                    End If
                                End If
                                'Marc 130 First Indicator 2 get from CCF 240^a ''if First Check CCF Tag =240 then Check Subfields a 's First Bigining 'a' there fore
                                If MChkFISbFildsVal.Chars(0) = "A" Or MChkFISbFildsVal.Chars(0) = "a" Then
                                    strbool = True
                                    GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                    M130FI2 = RetCCFVal(ArrayCount)
                                    FillBibRecAry(MarcTagSrNo, "730", "22", MarcTagSbFldSrNo, "a", M130FI2)
                                    'Marc 130$n get from CCF 240^b (if First occurance)
                                    GETTagVal(CCFTable, "240", "^b", RetCCFVal)
                                    M130n = RetCCFVal(ArrayCount)
                                    If M130n <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "22", MarcTagSbFldSrNo, "n", M130n)
                                    End If

                                    'Marc 130$p get from CCF 240^c (if First occurance)
                                    GETTagVal(CCFTable, "240", "^c", RetCCFVal)
                                    M130p = RetCCFVal(ArrayCount)
                                    If M130p <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "22", MarcTagSbFldSrNo, "p", M130p)
                                    End If

                                    'Marc 130$k get from CCF 240^d (if First occurance)
                                    GETTagVal(CCFTable, "240", "^d", RetCCFVal)
                                    M130k = RetCCFVal(ArrayCount)
                                    If M130k <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "22", MarcTagSbFldSrNo, "k", M130k)
                                    End If

                                    'Marc 130$c get from CCF 240^e (if First occurance)
                                    GETTagVal(CCFTable, "240", "^e", RetCCFVal)
                                    M130c = RetCCFVal(ArrayCount)
                                    If M130c <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "22", MarcTagSbFldSrNo, "c", M130c)
                                    End If

                                    'Marc 130$s get from CCF 240^f (if First occurance)
                                    GETTagVal(CCFTable, "240", "^f", RetCCFVal)
                                    M130s = RetCCFVal(ArrayCount)
                                    If M130s <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "22", MarcTagSbFldSrNo, "s", M130s)
                                    End If
                                End If
                            End If
                            'Marc 130 First Indicator 4 get from CCF 240^a if First Check CCF Tag =240 then Check Subfields a 's First Bigining 'the' there fore
                            If MChkFISbFildsVal.Length >= 3 Then
                                If MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "THE" Or MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "the" Or MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "THe" Or MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "ThE" Or MChkFISbFildsVal.Chars(0) & MChkFISbFildsVal.Chars(1) & MChkFISbFildsVal.Chars(2) = "tHE" Then
                                    GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                    M130FI4 = RetCCFVal(ArrayCount)
                                    FillBibRecAry(MarcTagSrNo, "730", "42", MarcTagSbFldSrNo, "a", M130FI4)
                                    'Marc 130$n get from CCF 240^b (if First occurance)
                                    GETTagVal(CCFTable, "240", "^b", RetCCFVal)
                                    M130n = RetCCFVal(ArrayCount)
                                    If M130n <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "42", MarcTagSbFldSrNo, "n", M130n)
                                    End If

                                    'Marc 130$p get from CCF 240^c (if First occurance)
                                    GETTagVal(CCFTable, "240", "^c", RetCCFVal)
                                    M130p = RetCCFVal(ArrayCount)
                                    If M130p <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "42", MarcTagSbFldSrNo, "p", M130p)
                                    End If

                                    'Marc 130$k get from CCF 240^d (if First occurance)
                                    GETTagVal(CCFTable, "240", "^d", RetCCFVal)
                                    M130k = RetCCFVal(ArrayCount)
                                    If M130k <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "42", MarcTagSbFldSrNo, "k", M130k)
                                    End If

                                    'Marc 130$c get from CCF 240^e (if First occurance)
                                    GETTagVal(CCFTable, "240", "^e", RetCCFVal)
                                    M130c = RetCCFVal(ArrayCount)
                                    If M130c <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "42", MarcTagSbFldSrNo, "c", M130c)
                                    End If

                                    'Marc 130$s get from CCF 240^f (if First occurance)
                                    GETTagVal(CCFTable, "240", "^f", RetCCFVal)
                                    M130s = RetCCFVal(ArrayCount)
                                    If M130s <> "Tag Not Available" Then
                                        FillBibRecAry(MarcTagSrNo, "730", "42", MarcTagSbFldSrNo, "s", M130s)
                                    End If
                                End If
                            End If
                            If M130FI2 Is Nothing And M130FI3 Is Nothing And M130FI4 Is Nothing Then
                                'Marc 130 First Indicator 0 get from CCF 240^a if First Check CCF Tag =240 then Check Subfields a 's First Bigining 'other' there fore
                                GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                M130FI0 = RetCCFVal(ArrayCount)
                                FillBibRecAry(MarcTagSrNo, "730", "02", MarcTagSbFldSrNo, "a", M130FI0)
                                'Marc 130$n get from CCF 240^b (if First occurance)
                                GETTagVal(CCFTable, "240", "^b", RetCCFVal)
                                M130n = RetCCFVal(ArrayCount)
                                If M130n <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "730", "02", MarcTagSbFldSrNo, "n", M130n)
                                End If

                                'Marc 130$p get from CCF 240^c (if First occurance)
                                GETTagVal(CCFTable, "240", "^c", RetCCFVal)
                                M130p = RetCCFVal(ArrayCount)
                                If M130p <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "730", "02", MarcTagSbFldSrNo, "p", M130p)
                                End If

                                'Marc 130$k get from CCF 240^d (if First occurance)
                                GETTagVal(CCFTable, "240", "^d", RetCCFVal)
                                M130k = RetCCFVal(ArrayCount)
                                If M130k <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "730", "02", MarcTagSbFldSrNo, "k", M130k)
                                End If

                                'Marc 130$c get from CCF 240^e (if First occurance)
                                GETTagVal(CCFTable, "240", "^e", RetCCFVal)
                                M130c = RetCCFVal(ArrayCount)
                                If M130c <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "730", "02", MarcTagSbFldSrNo, "c", M130c)
                                End If

                                'Marc 130$s get from CCF 240^f (if First occurance)
                                GETTagVal(CCFTable, "240", "^f", RetCCFVal)
                                M130s = RetCCFVal(ArrayCount)
                                If M130s <> "Tag Not Available" Then
                                    FillBibRecAry(MarcTagSrNo, "730", "02", MarcTagSbFldSrNo, "s", M130s)
                                End If
                            End If
                            MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                            MarcTagSrNo = MarcTagSrNo + 1
                        End If
                    End If
                End If
            Next
        End If

        'Marc 210$a get from CCF 201^b
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "201", "^b", RetCCFVal)
        M210a = RetCCFVal(0)
        If M210a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1               '(if First occurance)
                GETTagVal(CCFTable, "201", "^b", RetCCFVal)
                M210a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "210", "0 ", MarcTagSbFldSrNo, "a", M210a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 222 here first indicator is'#'and second indicator is 0,2,3,4
        'Marc 222$a getfrom 201^a (Chek 201 then check  a,an,the,other )
        'Marc 222 get from CCF201^a
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "201", "^a", RetCCFVal)
        MChkSISbFildsVal = RetCCFVal(0)
        If MChkSISbFildsVal <> "Tag Not Available" Then
            'Marc 222 Secind Indicator 3 get from CCF 201^a ''if First Check CCF Tag =201 then Check Subfields a 's First Bigining 'AN' there fore
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1                '(if First occurance)
                GETTagVal(CCFTable, "201", "^a", RetCCFVal)
                MChkSISbFildsVal = RetCCFVal(ArrayCount)
                If MChkSISbFildsVal.Length >= 1 Then
                    If MChkSISbFildsVal.Chars(0) = "A" Or MChkSISbFildsVal.Chars(0) = "a" Then
                        strboole = True
                        GETTagVal(CCFTable, "201", "^a", RetCCFVal)
                        M222SI2a = RetCCFVal(ArrayCount)
                    Else
                        strbool = False
                    End If
                    If strboole = True Then
                        If MChkSISbFildsVal.Length >= 2 Then
                            If MChkSISbFildsVal.Chars(1) = "N" Or MChkSISbFildsVal.Chars(1) = "n" Then
                                GETTagVal(CCFTable, "201", "^a", RetCCFVal)
                                M222SI3a = RetCCFVal(ArrayCount)
                                FillBibRecAry(14, "222", " 3", MarcTagSbFldSrNo, "a", M222SI3a)
                                'Marc 222 Secind Indicator 3 get from CCF 201^a ''if First Check CCF Tag =201 then Check Subfields a 's First Bigining 'A' there fore
                            End If
                        End If
                    End If
                    If MChkSISbFildsVal.Chars(0) = "A" Or MChkSISbFildsVal.Chars(0) = "a" Then
                        strbool = True
                        GETTagVal(CCFTable, "201", "^a", RetCCFVal)
                        M222SI2a = RetCCFVal(ArrayCount)
                        FillBibRecAry(MarcTagSrNo, "222", " 2", MarcTagSbFldSrNo, "a", M222SI2a)
                    End If
                End If

                'Marc 222 Secind Indicator 3 get from CCF 201^a ''if First Check CCF Tag =201 then Check Subfields a 's First Bigining 'THE' there fore

                If MChkSISbFildsVal.Length >= 3 Then
                    If MChkSISbFildsVal.Chars(0) & MChkSISbFildsVal.Chars(1) & MChkSISbFildsVal.Chars(2) = "THE" Or MChkSISbFildsVal.Chars(0) & MChkSISbFildsVal.Chars(1) & MChkSISbFildsVal.Chars(2) = "the" Or MChkSISbFildsVal.Chars(0) & MChkSISbFildsVal.Chars(1) & MChkSISbFildsVal.Chars(2) = "THe" Or MChkSISbFildsVal.Chars(0) & MChkSISbFildsVal.Chars(1) & MChkSISbFildsVal.Chars(2) = "ThE" Or MChkSISbFildsVal.Chars(0) & MChkSISbFildsVal.Chars(1) & MChkSISbFildsVal.Chars(2) = "tHE" Then
                        GETTagVal(CCFTable, "201", "^a", RetCCFVal)
                        M222SI4a = RetCCFVal(ArrayCount)
                        FillBibRecAry(MarcTagSrNo, "222", " 4", 1, "a", M222SI4a)
                    End If
                End If
                If M222SI2a Is Nothing And M222SI3a Is Nothing And M222SI4a Is Nothing Then
                    'Marc 222 Secind Indicator 3 get from CCF 201^a ''if First Check CCF Tag =201 then Check Subfields a 's First Bigining 'other' there fore
                    GETTagVal(CCFTable, "201", "^a", RetCCFVal)
                    M222SI0a = RetCCFVal(ArrayCount)
                    If M222SI2a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "222", " 0", MarcTagSbFldSrNo, "a", M222SI0a)
                    End If
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 240$a get from CCF 240^a and FI=0 and SI=0,2,3,4 as other,a,an,the same as Marc 222$a
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "240", "^a", RetCCFVal)
        MChkSISbFlds240Val = RetCCFVal(0)
        If MChkSISbFlds240Val <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then '(First Occurance)
                    GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                    MChkSISbFlds240Val = RetCCFVal(ArrayCount)
                    If MChkSISbFlds240Val.Length >= 1 Then
                        If MChkSISbFlds240Val.Chars(0) = "A" Or MChkSISbFlds240Val.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                            M240SI2a = RetCCFVal(ArrayCount)
                            MChkSISbFlds240Val = "A Dinesh"
                        Else
                            strbool = False
                        End If
                        'Marc 240$a get from CCF 240^a and FI=0 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If MChkSISbFlds240Val.Length >= 2 Then
                                If MChkSISbFlds240Val.Chars(1) = "N" Or MChkSISbFlds240Val.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                                    M240SI3a = RetCCFVal(ArrayCount)
                                    FillBibRecAry(MarcTagSrNo, "240", "03", MarcTagSbFldSrNo, "a", M240SI3a)
                                End If
                            End If
                        End If
                        'Marc 240$a get from CCF 240^a and FI=0 and SI=2 if "A" is Come
                        If MChkSISbFlds240Val.Chars(0) = "A" Or MChkSISbFlds240Val.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                            M240SI2a = RetCCFVal(ArrayCount)
                            FillBibRecAry(MarcTagSrNo, "240", "02", MarcTagSbFldSrNo, "a", M240SI2a)
                        End If
                    End If
                    'Marc 240$a get from CCF 240^a and FI=0 and SI=4 if "THE" is Come
                    If MChkSISbFlds240Val.Length >= 3 Then
                        If MChkSISbFlds240Val.Chars(0) & MChkSISbFlds240Val.Chars(1) & MChkSISbFlds240Val.Chars(2) = "THE" Or MChkSISbFlds240Val.Chars(0) & MChkSISbFlds240Val.Chars(1) & MChkSISbFlds240Val.Chars(2) = "the" Or MChkSISbFlds240Val.Chars(0) & MChkSISbFlds240Val.Chars(1) & MChkSISbFlds240Val.Chars(2) = "THe" Or MChkSISbFlds240Val.Chars(0) & MChkSISbFlds240Val.Chars(1) & MChkSISbFlds240Val.Chars(2) = "ThE" Or MChkSISbFlds240Val.Chars(0) & MChkSISbFlds240Val.Chars(1) & MChkSISbFlds240Val.Chars(2) = "tHE" Then
                            GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                            M240SI4a = RetCCFVal(ArrayCount)
                            FillBibRecAry(MarcTagSrNo, "240", "04", 1, "a", M240SI4a)
                        End If
                    End If
                    If M240SI2a Is Nothing And M240SI3a Is Nothing And M240SI4a Is Nothing Then
                        'Marc 240$a get from CCF 240^a and FI=0 and SI=0 if"A","THE" "AN" is no one avilable
                        GETTagVal(CCFTable, "240", "^a", RetCCFVal)
                        M240SI0a = RetCCFVal(ArrayCount)
                        If M240SI0a <> "Tag Not Available" Then
                            FillBibRecAry(MarcTagSrNo, "240", "00", MarcTagSbFldSrNo, "a", M240SI0a)
                        End If
                    End If
                End If
            Next
        End If
        '---------------------------------------------------------------------------------------------------------------------
        'PENDING:::
        'Marc 245 Check Marc 100,110,111,130 any one are present and first indicator is '1'else '0' and second indicator check 'a,an,the,other then
        'Marc 245$a get from 200^a and check 
        'MarcTagSrNo = 1
        'MarcTagSbFldSrNo = 1
        If M100 <> "Tag Not Available" Or M110a <> "Tag Not Available" Or M111a <> "Tag Not Available" Or M130 <> "Tag Not Available" Then
            GETTagVal(CCFTable, "200", "^b", RetCCFVal)
            M245c = RetCCFVal(0)
            GETTagVal(CCFTable, "203", "^a", RetCCFVal)
            M245c203a = RetCCFVal(0)
            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
            M245Chkval = RetCCFVal(0)
            ArrLength = RetCCFVal.Length
            GETTagVal(CCFTable, "210", "^a", RetCCFVal)
            M245b = RetCCFVal(0)
            GETTagVal(CCFTable, "210", "^b", RetCCFVal)
            M245 = RetCCFVal(0)
            For ArrayCount = 0 To ArrLength - 1
                If (M245Chkval <> "Tag Not Available") And (M245c <> "Tag Not Available" Or M245c203a <> "Tag Not Available") And (M245b <> "Tag Not Available") And (M245 <> "Tag Not Available") Then
                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(ArrayCount)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "/" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "13", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "12", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "/" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "14", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "10", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If

                    'Marc 245$c get from 200^b or marc 245$c get from CCF 203^a   ??????
                    GETTagVal(CCFTable, "200", "^b", RetCCFVal)
                    M245c = RetCCFVal(0) & " " & "=" & " "
                    If M245c <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                    Else
                        GETTagVal(CCFTable, "203", "^a", RetCCFVal)
                        M245c = RetCCFVal(0) & " " & "=" & " "
                        If M245c <> "Tag Not Available" Then
                            FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                        End If
                    End If

                    'Marc 245$b get from CCF 210^a/ CCF 210^b
                    GETTagVal(CCFTable, "210", "^a", RetCCFVal)
                    M245b = RetCCFVal(0)
                    GETTagVal(CCFTable, "210", "^b", RetCCFVal)
                    M245 = RetCCFVal(0)
                    M245ab = M245b & " " & "/" & " " & M245
                    FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "b", M245ab)

                ElseIf (M245Chkval <> "Tag Not Available") And (M245c <> "Tag Not Available" Or M245c203a <> "Tag Not Available") And (M245b <> "Tag Not Available") Then

                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "=" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "13", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "=" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "12", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "=" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "14", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "=" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "10", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If

                    'Marc 245$b get from CCF 210^a
                    GETTagVal(CCFTable, "210", "^a", RetCCFVal)
                    M245b = RetCCFVal(0) & " " & "/" & " "
                    FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "b", M245b)


                    'Marc 245$c get from 200^b or marc 245$c get from CCF 203^a   ??????
                    GETTagVal(CCFTable, "200", "^b", RetCCFVal)
                    M245c = RetCCFVal(0)
                    If M245c <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                    Else
                        GETTagVal(CCFTable, "203", "^a", RetCCFVal)
                        M245c = RetCCFVal(0)
                        If M245c <> "Tag Not Available" Then
                            FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                        End If
                    End If
                ElseIf (M245Chkval <> "Tag Not Available") And (M245b <> "Tag Not Available") Then

                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(ArrayCount)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "=" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "13", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "=" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "12", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "=" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "14", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "=" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "10", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If

                    'Marc 245$b get from CCF 210^a
                    GETTagVal(CCFTable, "210", "^a", RetCCFVal)
                    M245b = RetCCFVal(0) & " " & "/" & " "
                    FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "b", M245b)

                ElseIf (M245Chkval <> "Tag Not Available") And (M245c <> "Tag Not Available" Or M245c203a <> "Tag Not Available") Then

                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "/" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "13", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "12", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "/" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "14", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "10", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If

                    'Marc 245$c get from 200^b or marc 245$c get from CCF 203^a   ??????
                    GETTagVal(CCFTable, "200", "^b", RetCCFVal)
                    M245c = RetCCFVal(0)
                    If M245c <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                    Else
                        GETTagVal(CCFTable, "203", "^a", RetCCFVal)
                        M245c = RetCCFVal(0)
                        If M245c <> "Tag Not Available" Then
                            FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                        End If
                    End If
                ElseIf (M245Chkval <> "Tag Not Available") And (M245c = "Tag Not Available" Or M245c203a = "Tag Not Available") And (M245b = "Tag Not Available") And (M245 = "Tag Not Available") Then
                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "/" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "13", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "12", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "/" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "14", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "10", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        Else ' if M100,M111,M130,M110 is not present then FI is 0
            GETTagVal(CCFTable, "200", "^b", RetCCFVal)
            M245c = RetCCFVal(0)
            GETTagVal(CCFTable, "203", "^a", RetCCFVal)
            M245c203a = RetCCFVal(0)
            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
            M245Chkval = RetCCFVal(0)
            ArrLength = RetCCFVal.Length
            GETTagVal(CCFTable, "210", "^a", RetCCFVal)
            M245b = RetCCFVal(0)
            GETTagVal(CCFTable, "210", "^b", RetCCFVal)
            M245 = RetCCFVal(0)
            For ArrayCount = 0 To ArrLength - 1
                If (M245Chkval <> "Tag Not Available") And (M245c <> "Tag Not Available" Or M245c203a <> "Tag Not Available") And (M245b <> "Tag Not Available") And (M245 <> "Tag Not Available") Then
                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "/" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "03", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "02", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "/" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "04", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "00", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If

                    'Marc 245$c get from 200^b or marc 245$c get from CCF 203^a   ??????
                    GETTagVal(CCFTable, "200", "^b", RetCCFVal)
                    M245c = RetCCFVal(0) & " " & "=" & " "
                    If M245c <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                    Else
                        GETTagVal(CCFTable, "203", "^a", RetCCFVal)
                        M245c = RetCCFVal(0) & " " & "=" & " "
                        If M245c <> "Tag Not Available" Then
                            FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                        End If
                    End If

                    'Marc 245$b get from CCF 210^a/ CCF 210^b
                    GETTagVal(CCFTable, "210", "^a", RetCCFVal)
                    M245b = RetCCFVal(0)
                    GETTagVal(CCFTable, "210", "^b", RetCCFVal)
                    M245 = RetCCFVal(0)
                    M245ab = M245b & " " & "/" & " " & M245
                    FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "b", M245ab)

                ElseIf (M245Chkval <> "Tag Not Available") And (M245c <> "Tag Not Available" Or M245c203a <> "Tag Not Available") And (M245b <> "Tag Not Available") Then

                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "=" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "03", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "=" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "02", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "=" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "04", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "=" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "00", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If

                    'Marc 245$b get from CCF 210^a
                    GETTagVal(CCFTable, "210", "^a", RetCCFVal)
                    M245b = RetCCFVal(0) & " " & "/" & " "
                    FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "b", M245b)


                    'Marc 245$c get from 200^b or marc 245$c get from CCF 203^a   ??????
                    GETTagVal(CCFTable, "200", "^b", RetCCFVal)
                    M245c = RetCCFVal(0)
                    If M245c <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                    Else
                        GETTagVal(CCFTable, "203", "^a", RetCCFVal)
                        M245c = RetCCFVal(0)
                        If M245c <> "Tag Not Available" Then
                            FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                        End If
                    End If
                ElseIf (M245Chkval <> "Tag Not Available") And (M245b <> "Tag Not Available") Then

                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "=" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "03", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "=" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "02", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "=" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "04", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "=" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "00", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If

                    'Marc 245$b get from CCF 210^a
                    GETTagVal(CCFTable, "210", "^a", RetCCFVal)
                    M245b = RetCCFVal(0) & " " & "/" & " "
                    FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "b", M245b)

                ElseIf (M245Chkval <> "Tag Not Available") And (M245c <> "Tag Not Available" Or M245c203a <> "Tag Not Available") Then

                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "/" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "03", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "02", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "/" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "04", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "00", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If

                    'Marc 245$c get from 200^b or marc 245$c get from CCF 203^a   ??????
                    GETTagVal(CCFTable, "200", "^b", RetCCFVal)
                    M245c = RetCCFVal(0)
                    If M245c <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                    Else
                        GETTagVal(CCFTable, "203", "^a", RetCCFVal)
                        M245c = RetCCFVal(0)
                        If M245c <> "Tag Not Available" Then
                            FillBibRecAry(MarcTagSrNo, "245", "  ", MarcTagSbFldSrNo, "c", M245c)
                        End If
                    End If
                ElseIf (M245Chkval <> "Tag Not Available") And (M245c = "Tag Not Available" Or M245c203a = "Tag Not Available") And (M245b = "Tag Not Available") And (M245 = "Tag Not Available") Then
                    If M245Chkval.Length >= 1 Then
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strboole = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0)
                        Else
                            strbool = False
                        End If
                        '                        'Marc 245$a get from CCF 200^a and FI=1 and SI=3 if "AN" is Come
                        If strboole = True Then
                            If M245Chkval.Length >= 2 Then
                                If M245Chkval.Chars(1) = "N" Or M245Chkval.Chars(1) = "n" Then
                                    GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                    M245SI3a = RetCCFVal(0) & " " & "/" & " "
                                    FillBibRecAry(MarcTagSrNo, "245", "03", MarcTagSbFldSrNo, "a", M245SI3a)
                                End If
                            End If
                        End If
                        If M245Chkval.Chars(0) = "A" Or M245Chkval.Chars(0) = "a" Then
                            strbool = True
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI2a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "02", MarcTagSbFldSrNo, "a", M245SI2a)
                        End If
                        If MChkSISbFlds240Val.Length >= 3 Then
                            If M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "the" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "THe" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "ThE" Or M245Chkval.Chars(0) & M245Chkval.Chars(1) & M245Chkval.Chars(2) = "tHE" Then
                                GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                                M245SI4a = RetCCFVal(0) & " " & "/" & " "
                                FillBibRecAry(MarcTagSrNo, "245", "04", 1, "a", M245SI4a)
                            End If
                        End If
                        If M245SI2a Is Nothing And M245SI3a Is Nothing And M245SI4a Is Nothing Then
                            'Marc 245$a get from CCF 200^a and FI=1 and SI=0 if"A","THE" "AN" is no one avilable
                            GETTagVal(CCFTable, "200", "^a", RetCCFVal)
                            M245SI0a = RetCCFVal(0) & " " & "/" & " "
                            FillBibRecAry(MarcTagSrNo, "245", "00", MarcTagSbFldSrNo, "a", M245SI0a)
                        End If
                    End If
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next

        End If
        '--------------------------------------------------------------------------------------------------------------------
        'Marc 246 get from CCF 230 
        'CCF 210
        'in 246 First Indicator =1 for SubFields ^b 1=SubTitle,2=SpinTitle,3=Cover Title,4=Added Title Page,5=Running Tilte,and FI=0 for 0=Other Title Or UnKnown Type
        'Second Indicatar=0 for 1=SubTitle
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "230", "^b", RetCCFVal)
        M246 = RetCCFVal(0)
        If M246 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                '(First Occurance)
                GETTagVal(CCFTable, "230", "^b", RetCCFVal)
                M246 = RetCCFVal(ArrayCount)
                'Check CCF 230^b if 1=SubTitle is present then
                If M246 = "1" Then
                    'Marc 246 10 $a get from CCF 230^a
                    GETTagVal(CCFTable, "230", "^a", RetCCFVal)
                    M246a = RetCCFVal(ArrayCount)
                    If M246a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "246", "10", MarcTagSbFldSrNo, "a", M246a)
                    End If

                    'Check CCF 230^b if 2=SpinTitle is present then 
                ElseIf M246 = "2" Then
                    'Marc 246 18 ^a get from CCF 230^a
                    GETTagVal(CCFTable, "230", "^a", RetCCFVal)
                    M246a = RetCCFVal(ArrayCount)
                    If M246a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "246", "18", MarcTagSbFldSrNo, "a", M246a)
                    End If

                    'Check 230^b if 3=Cover Title is present then 
                ElseIf M246 = "3" Then
                    'Marc 246 14 ^a get from CCF 230^a
                    GETTagVal(CCFTable, "230", "^a", RetCCFVal)
                    M246a = RetCCFVal(ArrayCount)
                    If M246a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "246", "14", MarcTagSbFldSrNo, "a", M246a)
                    End If

                    'Check 230^b if 4=Added Title Page is present then 
                ElseIf M246 = "4" Then
                    'Marc 246  MarcTagSrNo ^a get from CCF 230^a
                    GETTagVal(CCFTable, "230", "^a", RetCCFVal)
                    M246a = RetCCFVal(ArrayCount)
                    If M246a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "246", "15", MarcTagSbFldSrNo, "a", M246a)
                    End If

                    'Check 230^b if 5=Running Tilte is present then 
                ElseIf M246 = "5" Then
                    'Marc 246 17 ^a get from CCF 230^a
                    GETTagVal(CCFTable, "230", "^a", RetCCFVal)
                    M246a = RetCCFVal(ArrayCount)
                    If M246a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "246", "17", MarcTagSbFldSrNo, "a", M246a)
                    End If

                    'Check 230^b if 0=Other Title Or UnKnown Type present then 
                ElseIf M246 = "0" Then
                    'Marc 246 03 ^a get from CCF 230^a
                    GETTagVal(CCFTable, "230", "^a", RetCCFVal)
                    M246a = RetCCFVal(ArrayCount)
                    If M246a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "246", "03", MarcTagSbFldSrNo, "a", M246a)
                    End If
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        Else
            'Marc 246 03 ^a get from CCF 230^a
            GETTagVal(CCFTable, "230", "^a", RetCCFVal)
            M246a = RetCCFVal(0)
            If M246a <> "Tag Not Available" Then
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    GETTagVal(CCFTable, "230", "^a", RetCCFVal)
                    M246a = RetCCFVal(0)
                    FillBibRecAry(MarcTagSrNo, "246", "03", MarcTagSbFldSrNo, "a", M246a)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
        End If

        GETTagVal(CCFTable, "210", "^a", RetCCFVal)
        M246a = RetCCFVal(0)
        'if CCF 210 is present then 
        If M246 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "210", "^a", RetCCFVal)
                M246a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "246", "21", MarcTagSbFldSrNo, "a", M246a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 250 FI And SI both are Blank
        'Marc 250$a get from  CCF 260^a
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "260", "^a", RetCCFVal)
        M250a = RetCCFVal(0)
        If M250a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "260", "^a", RetCCFVal)
                M250a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "250", "  ", MarcTagSbFldSrNo, "a", M250a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 250$b get from  CCF 260^b
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "260", "^b", RetCCFVal)
        M250b = RetCCFVal(0)
        If M250b <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "260", "^b", RetCCFVal)
                M250b = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "250", "  ", MarcTagSbFldSrNo, "b", M250b)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 260 FI and SI Both are Blank 
        'Marc 260$a get from CCF 400^a 
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "400", "^a", RetCCFVal)
        M260a = RetCCFVal(0)
        If M260a <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "400", "^a", RetCCFVal)
                M260a = RetCCFVal(ArrayCount) & ":"
                FillBibRecAry(MarcTagSrNo, "260", "  ", MarcTagSbFldSrNo, "a", M260a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        Else
            'Marc 260$a get from CCF 440^e
            GETTagVal(CCFTable, "440", "^e", RetCCFVal)
            M260a = RetCCFVal(0)
            If M260a <> "Tag Not Available" Then
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    GETTagVal(CCFTable, "440", "^e", RetCCFVal)
                    M260a = RetCCFVal(ArrayCount) & ":"
                    FillBibRecAry(MarcTagSrNo, "260", "  ", MarcTagSbFldSrNo, "a", M260a)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
        End If

        'Marc 260$b get from CCF 400^b
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "400", "^b", RetCCFVal)
        M260b = RetCCFVal(0)
        If M260b <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "400", "^b", RetCCFVal)
                M260b = RetCCFVal(ArrayCount) & ","
                FillBibRecAry(MarcTagSrNo, "260", "  ", MarcTagSbFldSrNo, "b", M260b)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 260$c get from CCF 440^a
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "440", "^a", RetCCFVal)
        M260c = RetCCFVal(0)
        If M260c <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "440", "^a", RetCCFVal)
                M260c = RetCCFVal(ArrayCount) & "."
                FillBibRecAry(MarcTagSrNo, "260", "  ", MarcTagSbFldSrNo, "c", M260c)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 260$e get from CCF 410^a
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "410", "^a", RetCCFVal)
        M260e = RetCCFVal(0)
        If M260e <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "410", "^a", RetCCFVal)
                M260e = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "260", "  ", MarcTagSbFldSrNo, "e", M260e)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 260$f get from CCF 410^b
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "410", "^b", RetCCFVal)
        M260f = RetCCFVal(0)
        If M260f <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "410", "^b", RetCCFVal)
                M260f = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "260", "  ", MarcTagSbFldSrNo, "f", M260f)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        '------------------------
        'MArc 270 FI and SI Both are Blank
        'Marc 270$a get from CCF 400^c
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        GETTagVal(CCFTable, "400", "^c", RetCCFVal)
        M270a = RetCCFVal(0)
        If M270a <> "Tag Not Available" Then
            ArrayCount = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "400", "^c", RetCCFVal)
                M270a = RetCCFVal(0)
                FillBibRecAry(MarcTagSrNo, "270", "  ", MarcTagSbFldSrNo, "a", M270a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 270$d get from CCF 400^d
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        GETTagVal(CCFTable, "400", "^d", RetCCFVal)
        M270d = RetCCFVal(0)
        If M270d <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "400", "^d", RetCCFVal)
                M270d = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "270", "  ", MarcTagSbFldSrNo, "d", M270d)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        '--------------------------------
        'Marc 300 FI and SI both are Blank
        'Marc 300$a get from CCF 460^a
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        GETTagVal(CCFTable, "460", "^a", RetCCFVal)
        M300a = RetCCFVal(0)
        If M300a <> "Tag Not Available" Then
            GETTagVal(CCFTable, "460", "^a", RetCCFVal)
            M300a = RetCCFVal(0) & "."
            ArrayCount = RetCCFVal.Length
            FillBibRecAry(MarcTagSrNo, "300", "  ", MarcTagSbFldSrNo, "a", M300a)
        End If

        'Marc 300$b get from CCF 460^b
        GETTagVal(CCFTable, "460", "^b", RetCCFVal)
        M300b = RetCCFVal(0)
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        If M300b <> "Tag Not Available" Then
            ArrayCount = RetCCFVal.Length
            FillBibRecAry(MarcTagSrNo, "300", "  ", MarcTagSbFldSrNo, "b", M300b)
        Else
            'Marc 300$b get from CCF 461^a
            GETTagVal(CCFTable, "461", "^a", RetCCFVal)
            M300b = RetCCFVal(0)
            If M300b <> "Tag Not Available" Then
                ArrayCount = RetCCFVal.Length
                FillBibRecAry(MarcTagSrNo, "300", "  ", MarcTagSbFldSrNo, "b", M300b)
            End If
        End If
        'Marc 300$c get from CCF 460^c
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        GETTagVal(CCFTable, "460", "^c", RetCCFVal)
        M300c = RetCCFVal(0)
        If M300c <> "Tag Not Available" Then
            ArrayCount = RetCCFVal.Length
            FillBibRecAry(MarcTagSrNo, "300", "  ", MarcTagSbFldSrNo, "c", M300c)
        Else
            'Marc 300$c get from CCF 462^a
            GETTagVal(CCFTable, "462", "^a", RetCCFVal)
            M300c = RetCCFVal(0)
            If M300c <> "Tag Not Available" Then
                ArrayCount = RetCCFVal.Length
                FillBibRecAry(MarcTagSrNo, "300", "  ", MarcTagSbFldSrNo, "c", M300c)
            End If
        End If
        'Marc 300$e get from CCF 460^d
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        GETTagVal(CCFTable, "460", "^d", RetCCFVal)
        M300e = RetCCFVal(0)
        If M300e <> "Tag Not Available" Then
            ArrayCount = RetCCFVal.Length
            FillBibRecAry(MarcTagSrNo, "300", "  ", MarcTagSbFldSrNo, "e", M300e)
        Else
            'Marc 300$e get from CCF 463^a
            GETTagVal(CCFTable, "463", "^a", RetCCFVal)
            M300e = RetCCFVal(0)
            If M300e <> "Tag Not Available" Then
                ArrayCount = RetCCFVal.Length
                FillBibRecAry(MarcTagSrNo, "300", "  ", MarcTagSbFldSrNo, "e", M300e)
            End If
        End If
        'Marc 362 FI is = 1 and SI is Blank 'Marc 362$a get from 440^a  'here Check if CCF 490^a is Present then
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        GETTagVal(CCFTable, "490", "^a", RetCCFVal)
        M362 = RetCCFVal(0)
        'MsgBox("M250a:" & M250a)
        If M362 <> "Tag Not Available" Then
            GETTagVal(CCFTable, "440", "^a", RetCCFVal)
            M362a = RetCCFVal(0)
            If M362a <> "Tag Not Available" Then
                'Marc 362^a get from CCF 490^a(440^a)
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    GETTagVal(CCFTable, "440", "^a", RetCCFVal)
                    M362a = RetCCFVal(ArrayCount)
                    M362aa = M362 & " " & "(" & M362a & ")" & "."
                    FillBibRecAry(MarcTagSrNo, "362", "1 ", MarcTagSbFldSrNo, "a", M362aa)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
        Else
            GETTagVal(CCFTable, "440", "^a", RetCCFVal)
            M362 = RetCCFVal(0)
            ArrLength = RetCCFVal.Length
            If M362 <> "Tag Not Available" Then
                For ArrayCount = 0 To ArrLength - 1
                    GETTagVal(CCFTable, "440", "^a", RetCCFVal)
                    M362a = RetCCFVal(ArrayCount) & "."
                    FillBibRecAry(MarcTagSrNo, "362", "1 ", MarcTagSbFldSrNo, "a", M362a)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
        End If
        'Marc 365$b get from CCF 465^a
        GETTagVal(CCFTable, "465", "^a", RetCCFVal)
        M365b = RetCCFVal(0)
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        If M365b <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "465", "^a", RetCCFVal)
                M365b = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "365", "  ", MarcTagSbFldSrNo, "a", M365b)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If
        'Marc 365$e get from CCF 465^b
        GETTagVal(CCFTable, "465", "^b", RetCCFVal)
        M365e = RetCCFVal(0)
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        If M365e <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                If ArrayCount = 0 Then
                    GETTagVal(CCFTable, "465", "^b", RetCCFVal)
                    M365e = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "365", "  ", MarcTagSbFldSrNo, "e", M365e)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                End If
            Next
        Else 'Marc 365$e get from CCF 467^a
            GETTagVal(CCFTable, "467", "^a", RetCCFVal)
            M365e = RetCCFVal(0)
            If M365e <> "Tag Not Available" Then
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    GETTagVal(CCFTable, "467", "^a", RetCCFVal)
                    M365e = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "365", "  ", MarcTagSbFldSrNo, "e", M365e)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
        End If
        'Marc 365$f get from CCF 465^c
        GETTagVal(CCFTable, "465", "^c", RetCCFVal)
        M365f = RetCCFVal(0)
        MarcTagSbFldSrNo = 1
        MarcTagSrNo = 1
        If M365f <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "465", "^c", RetCCFVal)
                M365f = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "365", "  ", MarcTagSbFldSrNo, "f", M365f)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        Else 'Marc 365$f get from CCF 468^a
            GETTagVal(CCFTable, "468", "^a", RetCCFVal)
            M365f = RetCCFVal(0)
            If M365f <> "Tag Not Available" Then
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    GETTagVal(CCFTable, "468", "^a", RetCCFVal)
                    M365f = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "365", "  ", MarcTagSbFldSrNo, "f", M365f)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
        End If

        'Marc 440 FI is blank and SI is 0,2,3,4 for other,A,AN,the check same as marc240
        'Marc 440$a get from CCF 480^a
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "480", "^a", RetCCFVal)
        MChkSI440SbFldsVal = RetCCFVal(0)
        ArrLength = RetCCFVal.Length
        If MChkSI440SbFldsVal <> "Tag Not Available" Then
            'Marc 440 Secind Indicator 3 get from CCF 480^a ''if First Check CCF Tag =480 then Check Subfields a 's First Bigining 'AN' there fore
            For ArrayCount = 0 To ArrLength - 1
                If MChkSI440SbFldsVal.Length >= 1 Then
                    If MChkSI440SbFldsVal.Chars(0) = "A" Or MChkSI440SbFldsVal.Chars(0) = "a" Then
                        strboole = True
                        GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                        M440SI2a = RetCCFVal(0)
                    Else
                        strbool = False
                    End If
                    If strboole = True Then
                        If MChkSI440SbFldsVal.Length >= 2 Then
                            If MChkSI440SbFldsVal.Chars(1) = "N" Or MChkSI440SbFldsVal.Chars(1) = "n" Then
                                'Marc 440$a get from CCF 480^b if 480^b is present then 
                                'Marc 440$a get from CCF 480^a/CCF 480^b
                                GETTagVal(CCFTable, "480", "^b", RetCCFVal)
                                M440b = RetCCFVal(0)
                                If M440b <> "Tag Not Available" Then
                                    ArrLength = RetCCFVal.Length
                                    GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                                    M440SI3a = RetCCFVal(0)
                                    'FillBibRecAry(MarcTagSrNo, "440", " 3", MarcTagSbFldSrNo, "a", M440SI3a)
                                    M440ab = M440SI3a & "/" & M440b
                                    FillBibRecAry(MarcTagSrNo, "440", " 3", MarcTagSbFldSrNo, "a", M440ab)
                                Else
                                    GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                                    M440SI3a = RetCCFVal(0)
                                    FillBibRecAry(MarcTagSrNo, "440", " 3", MarcTagSbFldSrNo, "a", M440SI3a)
                                End If

                                'Marc 440$v get from CCF 480^c
                                GETTagVal(CCFTable, "480", "^c", RetCCFVal)
                                M440v = RetCCFVal(0)
                                If M440v <> "Tag Not Available" Then
                                    ArrLength = RetCCFVal.Length
                                    FillBibRecAry(MarcTagSrNo, "440", "  ", MarcTagSbFldSrNo, "v", M440v)
                                End If

                                'Marc 440$x get from CCF 480^d
                                GETTagVal(CCFTable, "480", "^d", RetCCFVal)
                                M440x = RetCCFVal(0)
                                If M440x <> "Tag Not Available" Then
                                    ArrLength = RetCCFVal.Length
                                    FillBibRecAry(MarcTagSrNo, "440", "  ", MarcTagSbFldSrNo, "x", M440x)
                                End If
                            End If
                        End If
                    End If

                    'Marc 440 Secind Indicator 2 get from CCF 480^a ''if First Check CCF Tag =480 then Check Subfields a 's First Bigining 'A' there fore
                    If MChkSI440SbFldsVal.Chars(0) = "A" Or MChkSI440SbFldsVal.Chars(0) = "a" Then
                        strbool = True
                        GETTagVal(CCFTable, "480", "^b", RetCCFVal)
                        M440b = RetCCFVal(0)
                        If M440b <> "Tag Not Available" Then
                            ArrLength = RetCCFVal.Length
                            GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                            M440SI2a = RetCCFVal(0)
                            M440ab = M440SI2a & "/" & M440b
                            FillBibRecAry(MarcTagSrNo, "440", " 2", MarcTagSbFldSrNo, "a", M440ab)
                        Else
                            GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                            M440SI2a = RetCCFVal(0)
                            FillBibRecAry(MarcTagSrNo, "440", " 2", MarcTagSbFldSrNo, "a", M440SI2a)
                        End If

                        'Marc 440$v get from CCF 480^c
                        GETTagVal(CCFTable, "480", "^c", RetCCFVal)
                        M440v = RetCCFVal(0)
                        If M440v <> "Tag Not Available" Then
                            ArrLength = RetCCFVal.Length
                            FillBibRecAry(MarcTagSrNo, "440", "  ", MarcTagSbFldSrNo, "v", M440v)
                        End If

                        'Marc 440$x get from CCF 480^d
                        GETTagVal(CCFTable, "480", "^d", RetCCFVal)
                        M440x = RetCCFVal(0)
                        If M440x <> "Tag Not Available" Then
                            ArrLength = RetCCFVal.Length
                            FillBibRecAry(MarcTagSrNo, "440", "  ", MarcTagSbFldSrNo, "x", M440x)
                        End If
                    End If
                End If

                If MChkSI440SbFldsVal.Length >= 3 Then
                    'Marc 440$a get from CCF 480^a and FI=0 and SI=4 if "THE"  is  avilable
                    If MChkSI440SbFldsVal.Chars(0) & MChkSI440SbFldsVal.Chars(1) & MChkSI440SbFldsVal.Chars(2) = "THE" Or MChkSI440SbFldsVal.Chars(0) & MChkSI440SbFldsVal.Chars(1) & MChkSI440SbFldsVal.Chars(2) = "the" Or MChkSI440SbFldsVal.Chars(0) & MChkSI440SbFldsVal.Chars(1) & MChkSI440SbFldsVal.Chars(2) = "THe" Or MChkSI440SbFldsVal.Chars(0) & MChkSI440SbFldsVal.Chars(1) & MChkSI440SbFldsVal.Chars(2) = "ThE" Or MChkSI440SbFldsVal.Chars(0) & MChkSI440SbFldsVal.Chars(1) & MChkSI440SbFldsVal.Chars(2) = "tHE" Then
                        GETTagVal(CCFTable, "480", "^b", RetCCFVal)
                        M440b = RetCCFVal(0)
                        If M440b <> "Tag Not Available" Then
                            ArrLength = RetCCFVal.Length
                            GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                            M440SI4a = RetCCFVal(0)
                            M440ab = M440SI4a & "/" & M440b
                            FillBibRecAry(MarcTagSrNo, "440", " 4", MarcTagSbFldSrNo, "a", M440ab)
                        Else
                            GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                            M440SI4a = RetCCFVal(0)
                            FillBibRecAry(MarcTagSrNo, "440", " 4", MarcTagSbFldSrNo, "a", M440SI4a)
                        End If

                        'Marc 440$v get from CCF 480^c
                        GETTagVal(CCFTable, "480", "^c", RetCCFVal)
                        M440v = RetCCFVal(0)
                        If M440v <> "Tag Not Available" Then
                            ArrLength = RetCCFVal.Length
                            FillBibRecAry(MarcTagSrNo, "440", "  ", MarcTagSbFldSrNo, "v", M440v)
                        End If

                        'Marc 440$x get from CCF 480^d
                        GETTagVal(CCFTable, "480", "^d", RetCCFVal)
                        M440x = RetCCFVal(0)
                        If M440x <> "Tag Not Available" Then
                            ArrLength = RetCCFVal.Length
                            FillBibRecAry(MarcTagSrNo, "440", "  ", MarcTagSbFldSrNo, "x", M440x)
                        End If
                    End If
                End If
                'Marc 440$a get from CCF 480^a and FI=0 and SI=0 if"A","THE" "AN" is no one avilable
                If M440SI2a Is Nothing And M440SI3a Is Nothing And M440SI4a Is Nothing Then
                    GETTagVal(CCFTable, "480", "^b", RetCCFVal)
                    M440b = RetCCFVal(0)
                    If M440b <> "Tag Not Available" Then
                        ArrLength = RetCCFVal.Length
                        GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                        M440SI0a = RetCCFVal(0)
                        M440ab = M440SI3a & "/" & M440b
                        FillBibRecAry(MarcTagSrNo, "440", " 0", MarcTagSbFldSrNo, "a", M440ab)
                    Else
                        GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                        M440SI0a = RetCCFVal(0)
                        FillBibRecAry(MarcTagSrNo, "440", " 0", MarcTagSbFldSrNo, "a", M440SI0a)
                    End If

                    'Marc 440$v get from CCF 480^c
                    GETTagVal(CCFTable, "480", "^c", RetCCFVal)
                    M440v = RetCCFVal(0)
                    If M440v <> "Tag Not Available" Then
                        ArrLength = RetCCFVal.Length
                        FillBibRecAry(MarcTagSrNo, "440", "  ", MarcTagSbFldSrNo, "v", M440v)
                    End If

                    'Marc 440$x get from CCF 480^d
                    GETTagVal(CCFTable, "480", "^d", RetCCFVal)
                    M440x = RetCCFVal(0)
                    If M440x <> "Tag Not Available" Then
                        ArrLength = RetCCFVal.Length
                        FillBibRecAry(MarcTagSrNo, "440", "  ", MarcTagSbFldSrNo, "x", M440x)
                    End If
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If
        ''Marc 440$a get from CCF 480^b if 480^b is present then 
        ''Marc 440$a get from CCF 480^a/CCF 480^b
        'GETTagVal(CCFTable, "480", "^b", RetCCFVal)
        'M440b = RetCCFVal(0)
        'If M440b <> "Tag Not Available" Then
        '    ArrLength = RetCCFVal.Length
        '    GETTagVal(CCFTable, "480", "^a", RetCCFVal)
        '    M440a = RetCCFVal(0)
        '    M440ab = M440a & "/" & M440b
        '    FillBibRecAry(MarcTagSrNo, "440", " 0", MarcTagSbFldSrNo, "a", M440ab)
        'End If
        ''Marc 440$v get from CCF 480^c
        'GETTagVal(CCFTable, "480", "^c", RetCCFVal)
        'M440v = RetCCFVal(0)
        'If M440v <> "Tag Not Available" Then
        '    ArrLength = RetCCFVal.Length
        '    FillBibRecAry(MarcTagSrNo, "440", "0", MarcTagSbFldSrNo, "v", M440v)
        'End If
        ''Marc 440$x get from CCF 480^d
        'GETTagVal(CCFTable, "480", "^d", RetCCFVal)
        'M440x = RetCCFVal(0)
        'If M440x <> "Tag Not Available" Then
        '    ArrLength = RetCCFVal.Length
        '    FillBibRecAry(MarcTagSrNo, "440", "0", MarcTagSbFldSrNo, "x", M440x)
        'End If

        'Marc 490 get from CCF 480(Repeatable Fields)
        'Marc 490 FI =0 and SI=blank
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "480", "^b", RetCCFVal)
        M490b = RetCCFVal(0)
        If M490b <> "Tag Not Available" Then
            'Marc 490 FI $a get from CCF 480^a but Check if CCF 480^b is present than value of CCF 480^b will goto
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "480", "^a", RetCCFVal)
                M490a = RetCCFVal(ArrayCount)
                M490ab = M490a & "/" & M490b
                FillBibRecAry(MarcTagSrNo, "490", "0 ", MarcTagSbFldSrNo, "a", M490ab)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        Else
            'Marc 490 FI $a get from CCF 480^a
            GETTagVal(CCFTable, "480", "^a", RetCCFVal)
            M490a = RetCCFVal(0)
            If M490a <> "Tag Not Available" Then
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    FillBibRecAry(MarcTagSrNo, "490", "0 ", MarcTagSbFldSrNo, "a", M490a)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
        End If
        'Marc 490 FI $v get value From CCF 480^c
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "480", "^c", RetCCFVal)
        M490 = RetCCFVal(0)
        If M490 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "480", "^c", RetCCFVal)
                M490v = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "490", "  ", MarcTagSbFldSrNo, "v", M490v)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 490 FI $x get value from CCF 480^d
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "480", "^d", RetCCFVal)
        M490 = RetCCFVal(0)
        If M490 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1

                GETTagVal(CCFTable, "480", "^d", RetCCFVal)
                M490x = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "490", "  ", MarcTagSbFldSrNo, "x", M490x)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1

            Next
        End If

        'Marc 500 get from CCF 500(Repeatable Fields)
        'MArc 500 FI=SI=Blank
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "500", "^a", RetCCFVal)
        M500 = RetCCFVal(0)
        If M500 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                'Marc 500$a get value from CCF 500^a
                GETTagVal(CCFTable, "500", "^a", RetCCFVal)
                M500a = RetCCFVal(ArrayCount) & "."
                FillBibRecAry(MarcTagSrNo, "500", "  ", MarcTagSbFldSrNo, "a", M500a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 501 get from CCF 510 FI=SI=Blank(Repeatable Fields) 
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "510", "^a", RetCCFVal)
        M501ChkSbFldsVal = RetCCFVal(0)
        If M501ChkSbFldsVal <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "510", "^a", RetCCFVal)
                M501ChkSbFldsVal = RetCCFVal(ArrayCount)
                If M501ChkSbFldsVal.Length >= 4 Then
                    'Check CCF 510^a if the value of CCF 510^a is begining with "with","WITH","With" then it will go to
                    'Marc 501$a get from CCF 510^a
                    'If M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "WITH" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "With" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "with" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "wITH" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "WiTH" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "WItH" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "WITh" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "wiTH" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "WIth" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "wIth" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "wiTh" Or M501ChkSbFldsVal.Chars(0) & M501ChkSbFldsVal.Chars(1) & M501ChkSbFldsVal.Chars(2) & M501ChkSbFldsVal.Chars(3) = "witH" Then
                    If (M501ChkSbFldsVal.Chars(0) = "w" Or M501ChkSbFldsVal.Chars(0) = "W") And (M501ChkSbFldsVal.Chars(1) = "i" Or M501ChkSbFldsVal.Chars(1) = "I") And (M501ChkSbFldsVal.Chars(2) = "t" Or M501ChkSbFldsVal.Chars(2) = "T") And (M501ChkSbFldsVal.Chars(3) = "h" Or M501ChkSbFldsVal.Chars(3) = "H") Then
                        GETTagVal(CCFTable, "510", "^a", RetCCFVal)
                        M501a = RetCCFVal(ArrayCount)
                        FillBibRecAry(MarcTagSrNo, "501", "  ", MarcTagSbFldSrNo, "a", M501a)
                    Else
                        'MArc 504$a FI=SI=Blank get from CCF 510^a
                        GETTagVal(CCFTable, "510", "^a", RetCCFVal)
                        M504a = RetCCFVal(ArrayCount) & "."
                        FillBibRecAry(MarcTagSrNo, "504", "  ", MarcTagSbFldSrNo, "a", M504a)
                    End If
                Else
                    'MArc 504$a FI=SI=Blank get from CCF 510^a
                    GETTagVal(CCFTable, "510", "^a", RetCCFVal)
                    M504a = RetCCFVal(ArrayCount) & "."
                    FillBibRecAry(MarcTagSrNo, "504", "  ", MarcTagSbFldSrNo, "a", M504a)
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 505 get from CCF 530 FI=8 SI=Balnk(Repeatable Fields)
        'MArc 505$a get from CCF 530^a
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "530", "^a", RetCCFVal)
        M505 = RetCCFVal(0)
        If M505 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "530", "^a", RetCCFVal)
                M505a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "505", "8 ", MarcTagSbFldSrNo, "a", M505a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 530$a FI=SI=Blank get from CCF 460^d (Repeatable Fields)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "460", "^d", RetCCFVal)
        M530 = RetCCFVal(0)
        If M530 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "460", "^d", RetCCFVal)
                M530a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "530", "  ", MarcTagSbFldSrNo, "a", M530a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 650  FI=Blank SI=4 get from CCF 620(Repeatable Fields)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "620", "^c", RetCCFVal)
        M650 = RetCCFVal(0)
        If M650 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "620", "^c", RetCCFVal)
                M650c = RetCCFVal(ArrayCount)
                'here Check if value of CCF 620^c is "0" then
                If M650c = "0" Then
                    'MArc 650 4 $a get from CCF 620^a
                    GETTagVal(CCFTable, "620", "^a", RetCCFVal)
                    M650a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "650", " 4", MarcTagSbFldSrNo, "a", M650a)
                    'else if Value is "1" then
                ElseIf M650c = "1" Then
                    'MArc 651 4 $a get from CCF 620^a
                    GETTagVal(CCFTable, "620", "^a", RetCCFVal)
                    M651a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "651", " 4", MarcTagSbFldSrNo, "a", M651a)
                    'else if Value is "2" then
                ElseIf M650c = "2" Then
                    'MArc 648 4 $a get from CCF 620^a
                    GETTagVal(CCFTable, "620", "^a", RetCCFVal)
                    M648a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "648", " 4", MarcTagSbFldSrNo, "a", M648a)
                Else
                    'else  'MArc 653 4 $a get from CCF 620^
                    GETTagVal(CCFTable, "620", "^a", RetCCFVal)
                    M653a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "653", "0 ", MarcTagSbFldSrNo, "a", M653a)
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        Else
            'else  'MArc 653 4 $a get from CCF 620^
            GETTagVal(CCFTable, "620", "^a", RetCCFVal)
            'Marc653a = RetCCFVal(0)
            M653a = RetCCFVal(0)
            If M653a <> "Tag Not Available" Then
                ArrLength = RetCCFVal.Length
                For ArrayCount = 0 To ArrLength - 1
                    GETTagVal(CCFTable, "620", "^a", RetCCFVal)
                    M653a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "653", "0 ", MarcTagSbFldSrNo, "a", M653a)
                    MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                    MarcTagSrNo = MarcTagSrNo + 1
                Next
            End If
        End If
        'MArc 740 get from value CCF 490(Repeatable Fields)
        'Marc 740 FI $a get from CCF 490^c
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "490", "^c", RetCCFVal)
        M740 = RetCCFVal(0)
        If M740 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "490", "^c", RetCCFVal)
                M740ChkSbFldsVal = RetCCFVal(ArrayCount)
                If M740ChkSbFldsVal.Length >= 1 Then
                    'check "a","an","the" are present in CCF 490^c then FI = 2,3,4 else "0" SI = Blank
                    If M740ChkSbFldsVal.Chars(0) = "A" Or M740ChkSbFldsVal.Chars(0) = "a" Then
                        strboole = True
                        GETTagVal(CCFTable, "490", "^c", RetCCFVal)
                        M740FI2a = RetCCFVal(ArrayCount)
                    Else
                        strbool = False
                    End If
                    If strboole = True Then
                        If M740ChkSbFldsVal.Length >= 2 Then
                            If M740ChkSbFldsVal.Chars(1) = "N" Or M740ChkSbFldsVal.Chars(1) = "n" Then
                                GETTagVal(CCFTable, "490", "^c", RetCCFVal)
                                M740FI3a = RetCCFVal(ArrayCount)
                                FillBibRecAry(14, "740", "3 ", MarcTagSbFldSrNo, "a", M740FI3a)
                                'Marc 222 Secind Indicator 3 get from CCF 201^a ''if First Check CCF Tag =201 then Check Subfields a 's First Bigining 'A' there fore
                            End If
                        End If
                    End If
                    If M740ChkSbFldsVal.Chars(0) = "A" Or M740ChkSbFldsVal.Chars(0) = "a" Then
                        strbool = True
                        GETTagVal(CCFTable, "490", "^c", RetCCFVal)
                        M740FI2a = RetCCFVal(ArrayCount)
                        FillBibRecAry(MarcTagSrNo, "740", "2 ", MarcTagSbFldSrNo, "a", M740FI2a)
                    End If
                End If
                If M740ChkSbFldsVal.Length >= 3 Then
                    If M740ChkSbFldsVal.Chars(0) & M740ChkSbFldsVal.Chars(1) & M740ChkSbFldsVal.Chars(2) = "THE" Or M740ChkSbFldsVal.Chars(0) & M740ChkSbFldsVal.Chars(1) & M740ChkSbFldsVal.Chars(2) = "the" Or M740ChkSbFldsVal.Chars(0) & M740ChkSbFldsVal.Chars(1) & M740ChkSbFldsVal.Chars(2) = "THe" Or M740ChkSbFldsVal.Chars(0) & M740ChkSbFldsVal.Chars(1) & M740ChkSbFldsVal.Chars(2) = "ThE" Or M740ChkSbFldsVal.Chars(0) & M740ChkSbFldsVal.Chars(1) & M740ChkSbFldsVal.Chars(2) = "tHE" Then
                        GETTagVal(CCFTable, "490", "^c", RetCCFVal)
                        M740FI4a = RetCCFVal(ArrayCount)
                        FillBibRecAry(MarcTagSrNo, "740", "4 ", MarcTagSbFldSrNo, "a", M740FI4a)
                    End If
                End If
                If M740FI2a Is Nothing And M740FI3a Is Nothing And M740FI4a Is Nothing Then
                    GETTagVal(CCFTable, "490", "^c", RetCCFVal)
                    M740FI0a = RetCCFVal(ArrayCount)
                    FillBibRecAry(MarcTagSrNo, "740", "0 ", MarcTagSbFldSrNo, "a", M740FI0a)
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If
        'Marc 800 get from CCF 480^b FI=1 SI=blank(Repeatable Fields)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "480", "^b", RetCCFVal)
        M800 = RetCCFVal(0)
        If M800 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                'Marc 800 FI $a get from 480^b(First Occuraance)
                GETTagVal(CCFTable, "480", "^b", RetCCFVal)
                M800a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "800", "1 ", MarcTagSbFldSrNo, "a", M800a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If
        'Marc 850$a get from CCF 020^a FI=SI=blank(Repeatable Fields)
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "020", "^a", RetCCFVal)
        M850 = RetCCFVal(0)
        If M850 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                GETTagVal(CCFTable, "020", "^a", RetCCFVal)
                M850a = RetCCFVal(ArrayCount)
                FillBibRecAry(MarcTagSrNo, "850", "  ", MarcTagSbFldSrNo, "a", M850a)
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If

        'Marc 852 get from CCF 020 FI=SI= Blank(Repeatable Fields)

        'Check CCF 610^c ClassiFication Scheme IF U,D,L then FI=8,1,0 SI=Blank
        MarcTagSrNo = 1
        MarcTagSbFldSrNo = 1
        GETTagVal(CCFTable, "610", "^c", RetCCFVal)
        M852 = RetCCFVal(0)
        If M852 <> "Tag Not Available" Then
            ArrLength = RetCCFVal.Length
            For ArrayCount = 0 To ArrLength - 1
                '(First Occurance Come)
                GETTagVal(CCFTable, "610", "^c", RetCCFVal)
                M852 = RetCCFVal(ArrayCount)
                If Asc(M852.Chars(0)) = 85 Or Asc(M852.Chars(0)) = 117 Then
                    'Marc 852 FI get from CCF 020^a
                    GETTagVal(CCFTable, "020", "^a", RetCCFVal)
                    M852a = RetCCFVal(0)
                    If M852a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "8 ", MarcTagSbFldSrNo, "a", M852a)
                    End If

                    'MArc 852 FI $k get from CCF 610^a
                    GETTagVal(CCFTable, "610", "^a", RetCCFVal)
                    M852k = RetCCFVal(ArrayCount)
                    If M852k <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "8 ", MarcTagSbFldSrNo, "k", M852k)
                    End If

                    'MArc 852 FI $m get from CCF 610^d
                    GETTagVal(CCFTable, "610", "^d", RetCCFVal)
                    M852m = RetCCFVal(ArrayCount)
                    If M852m <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "8 ", MarcTagSbFldSrNo, "m", M852m)
                    End If


                    'Marc 852 FI $p get from CCF 900^a
                    GETTagVal(CCFTable, "900", "^a", RetCCFVal)
                    M852p = RetCCFVal(ArrayCount)
                    If M852p <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "8 ", MarcTagSbFldSrNo, "p", M852p)
                    End If

                ElseIf Asc(M852.Chars(0)) = 68 Or Asc(M852.Chars(0)) = 100 Then
                    'Marc 852 FI get from CCF 020^a
                    GETTagVal(CCFTable, "020", "^a", RetCCFVal)
                    M852a = RetCCFVal(0)
                    If M852a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "1 ", MarcTagSbFldSrNo, "a", M852a)
                    End If
                    'MArc 852 FI $k get from CCF 610^a
                    GETTagVal(CCFTable, "610", "^a", RetCCFVal)
                    M852k = RetCCFVal(ArrayCount)
                    If M852k <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "1", MarcTagSbFldSrNo, "k", M852k)
                    End If
                    'MArc 852 FI $m get from CCF 610^d
                    GETTagVal(CCFTable, "610", "^d", RetCCFVal)
                    M852m = RetCCFVal(ArrayCount)
                    If M852m <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "1", MarcTagSbFldSrNo, "m", M852m)
                    End If

                    'Marc 852 FI $p get from CCF 900^a
                    GETTagVal(CCFTable, "900", "^a", RetCCFVal)
                    M852p = RetCCFVal(ArrayCount)
                    If M852p <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "1", MarcTagSbFldSrNo, "p", M852p)
                    End If

                ElseIf Asc(M852.Chars(0)) = 76 Or Asc(M852.Chars(0)) = 108 Then
                    'Marc 852 FI get from CCF 020^a
                    GETTagVal(CCFTable, "020", "^a", RetCCFVal)
                    M852a = RetCCFVal(0)
                    If M852a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "0 ", MarcTagSbFldSrNo, "a", M852a)
                    End If

                    'MArc 852 FI $k get from CCF 610^a
                    GETTagVal(CCFTable, "610", "^a", RetCCFVal)
                    M852k = RetCCFVal(ArrayCount)
                    If M852k <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "0", MarcTagSbFldSrNo, "k", M852k)
                    End If

                    'MArc 852 FI $m get from CCF 610^d
                    GETTagVal(CCFTable, "610", "^d", RetCCFVal)
                    M852m = RetCCFVal(ArrayCount)
                    If M852m <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "0", MarcTagSbFldSrNo, "m", M852m)
                    End If

                    'Marc 852 FI $p get from CCF 900^a
                    GETTagVal(CCFTable, "900", "^a", RetCCFVal)
                    M852p = RetCCFVal(ArrayCount)
                    If M852p <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "0", MarcTagSbFldSrNo, "p", M852p)
                    End If
                Else
                    'Marc 852 FI get from CCF 020^a
                    GETTagVal(CCFTable, "020", "^a", RetCCFVal)
                    M852a = RetCCFVal(0)
                    If M852a <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "  ", MarcTagSbFldSrNo, "a", M852a)
                    End If

                    'MArc 852 FI $k get from CCF 610^a
                    GETTagVal(CCFTable, "610", "^a", RetCCFVal)
                    M852k = RetCCFVal(ArrayCount)
                    If M852k <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", " ", MarcTagSbFldSrNo, "k", M852k)
                    End If
                    'MArc 852 FI $m get from CCF 610^d
                    GETTagVal(CCFTable, "610", "^d", RetCCFVal)
                    M852k = RetCCFVal(ArrayCount)
                    If M852m <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "  ", MarcTagSbFldSrNo, "m", M852m)
                    End If

                    'Marc 852 FI $p get from CCF 900^a
                    GETTagVal(CCFTable, "900", "^a", RetCCFVal)
                    M852p = RetCCFVal(ArrayCount)
                    If M852p <> "Tag Not Available" Then
                        FillBibRecAry(MarcTagSrNo, "852", "  ", MarcTagSbFldSrNo, "p", M852p)
                    End If
                End If
                MarcTagSbFldSrNo = MarcTagSbFldSrNo + 1
                MarcTagSrNo = MarcTagSrNo + 1
            Next
        End If
        ChkBadBool = True
    End Function
    Private Sub GetMarcRecId()

        RecId = RecId + 1
        'PMAX.Text = RecId

    End Sub
    '    Private Function FillBibRecAry(ByVal fTagSrNo As Integer, _
    'ByVal fTag As String, ByVal fInd As String, ByVal fSbFldSrNo As Integer, ByVal fSbFld As String, ByVal fFValue As String)
    '        If fFValue <> "" Then
    '            ReDim Preserve BibRecAry(ArrayCount)  'redefine length of bibrecary
    '            FldsAry.GetFldsAry(BibRecAry, ArrayCount, MarcRecID, fTagSrNo, fTag, fInd, fSbFldSrNo, fSbFld, fFValue) 'call GetFldsAry function to fill BibRecAry with record values
    '            FldsUpdate.FillBibDS(BibRecAry, dbcon)
    '        End If
    '    End Function
    Private Function FillBibRecAry(ByVal TagSrNo As Integer, _
ByVal Tag As String, ByVal Ind As String, ByVal SbFldSrNo As Integer, ByVal SbFld As String, ByVal FValue As String)
        If FValue <> "" Then

            rowNo = rowNo + 1
            'if file is alredy exists then Value will append
            If File.Exists(Application.StartupPath & "\Data.csv") Then
                FileClose(2)
                File.AppendAllText(Application.StartupPath & "\Data.csv", "" & rowNo & "," & RecId & "," & TagSrNo & " ," & Tag & " ," & Ind & " ," & SbFldSrNo & " , " & SbFld & ", " & Trim(dbcon.RemoveComa(FValue)) & "" & Chr(13) & Chr(10))
            Else
                'if file is Create first then Value will insert
                FileOpen(2, Application.StartupPath & "\Data.csv", OpenMode.Binary) 'bad record is come then it is set in "c:\BadRecord\record.txt
                FilePut(2, "RowNo,RecID,TagSrNo,Tag,Ind,SbFldSrNo,SbFld,FValue" & Chr(13) & Chr(10))
                FilePut(2, "" & rowNo & "," & RecId & "," & TagSrNo & " ," & Tag & " ," & Ind & " ," & SbFldSrNo & " , " & SbFld & ", " & Trim(dbcon.RemoveComa(FValue)) & "" & Chr(13) & Chr(10))
            End If

            'outFile.WriteLine(MarcRecID, fTagSrNo, fTag, fInd, fSbFldSrNo, fSbFld, Trim(dbcon.check_single_quote(fFValue))) 'call GetFldsAry function to fill BibRecAry with record values

        End If
    End Function


    Private Sub GetMfxfld00to05(ByVal Mfxfld00to05 As String, ByRef Mfxfld0to5 As String)
        Dim FIndex1, LIndex1, FIndex2, Chkindex As Integer
        Dim Index, ChkIndex1, ChkIndex2, MfxldYY, MfxfldMM, MfxfldDD As String
        Dim dtdate As DateTime
        Dim DDate As String
        'Dim Mfxfld0to5 As String
        'CCF 022^a date is in SOUL Format

        If Mfxfld00to05 <> "Tag Not Available" Then
            Chkindex = Mfxfld00to05.IndexOf("/")
            If Chkindex <> -1 Then
                ChkIndex1 = "/"
            Else
                ChkIndex1 = "-"
            End If
            If Mfxfld00to05.Length = 10 Then
                FIndex1 = Mfxfld00to05.IndexOf(ChkIndex1)
                LIndex1 = Mfxfld00to05.LastIndexOf(ChkIndex1)
                'if date is in yyyy/mm/dd format
                'if date is in yyyy-mm-dd format
                If FIndex1 = 4 And LIndex1 = 7 Then
                    MfxldYY = Mfxfld00to05.Substring(2, 2)
                    MfxfldMM = Mfxfld00to05.Substring(5, 2)
                    MfxfldDD = Mfxfld00to05.Substring(8, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                    'if date is in dd/mm/yyyy format
                    'if date is in dd-mm-yyyy format
                ElseIf FIndex1 = 2 And LIndex1 = 5 Then
                    MfxfldDD = Mfxfld00to05.Substring(0, 2)
                    MfxfldMM = Mfxfld00to05.Substring(3, 2)
                    MfxldYY = Mfxfld00to05.Substring(8, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                End If
            ElseIf Mfxfld00to05.Length = 9 Then
                FIndex1 = Mfxfld00to05.IndexOf(ChkIndex1)
                LIndex1 = Mfxfld00to05.LastIndexOf(ChkIndex1)
                If FIndex1 = 4 And LIndex1 = 6 Then  'if date is in yyyy/m/dd format
                    MfxldYY = Mfxfld00to05.Substring(2, 2)
                    MfxfldMM = "0" & Mfxfld00to05.Substring(5, 1)
                    MfxfldDD = Mfxfld00to05.Substring(7, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 4 And LIndex1 = 7 Then ' if date is in yyyy/mm/d format
                    MfxldYY = Mfxfld00to05.Substring(2, 2)
                    MfxfldMM = Mfxfld00to05.Substring(5, 2)
                    MfxfldDD = "0" & Mfxfld00to05.Substring(8, 1)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 1 And LIndex1 = 4 Then ' if date is in d/mm/yyyy format
                    MfxfldDD = "0" & Mfxfld00to05.Substring(0, 1)
                    MfxfldMM = Mfxfld00to05.Substring(2, 2)
                    MfxldYY = Mfxfld00to05.Substring(7, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 2 And LIndex1 = 4 Then 'if date is in dd/m/yyyy format
                    MfxfldDD = Mfxfld00to05.Substring(0, 2)
                    MfxfldMM = "0" & Mfxfld00to05.Substring(3, 2)
                    MfxldYY = Mfxfld00to05.Substring(7, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                End If
                'if date in dd/mm/yy format
                'if date is in dd-mm-yy format
            ElseIf Mfxfld00to05.Length = 8 Then
                FIndex1 = Mfxfld00to05.IndexOf(ChkIndex1)
                LIndex1 = Mfxfld00to05.LastIndexOf(ChkIndex1)
                If FIndex1 = 2 And LIndex1 = 5 Then ' if date is in dd/mm/yy format
                    MfxfldDD = Mfxfld00to05.Substring(0, 2)
                    MfxfldMM = Mfxfld00to05.Substring(3, 2)
                    MfxldYY = Mfxfld00to05.Substring(6, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 4 And LIndex1 = 6 Then ' if date is in yyyy/m/d format
                    MfxldYY = Mfxfld00to05.Substring(2, 2)
                    MfxfldMM = "0" & Mfxfld00to05.Substring(5, 1)
                    MfxfldDD = "0" & Mfxfld00to05.Substring(7, 1)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 1 And LIndex1 = 3 Then ' if date is in d/m/yyyy format
                    MfxfldDD = "0" & Mfxfld00to05.Substring(0, 1)
                    MfxfldMM = "0" & Mfxfld00to05.Substring(2, 1)
                    MfxldYY = Mfxfld00to05.Substring(6, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD

                ElseIf FIndex1 = -1 And LIndex1 = -1 Then   'if date is in YYYYMMDD this is Inflibnet's Suggetion to all users
                    MfxldYY = Mfxfld00to05.Substring(2, 2)
                    MfxfldMM = Mfxfld00to05.Substring(4, 2)
                    MfxfldDD = Mfxfld00to05.Substring(6, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                End If
            ElseIf Mfxfld00to05.Length = 7 Then
                FIndex1 = Mfxfld00to05.IndexOf(ChkIndex1)
                LIndex1 = Mfxfld00to05.LastIndexOf(ChkIndex1)
                If FIndex1 = 2 And LIndex1 = 4 Then ' if date is in d/m/yy format
                    MfxfldDD = Mfxfld00to05.Substring(0, 2)
                    MfxfldMM = "0" & Mfxfld00to05.Substring(3, 1)
                    MfxldYY = Mfxfld00to05.Substring(5, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 1 And LIndex1 = 4 Then ' if date is in dd/m/yy format
                    MfxfldDD = Mfxfld00to05.Substring(0, 1)
                    MfxfldMM = "0" & Mfxfld00to05.Substring(2, 2)
                    MfxldYY = Mfxfld00to05.Substring(5, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                End If
            ElseIf Mfxfld00to05.Length = 6 Then
                FIndex1 = Mfxfld00to05.IndexOf(ChkIndex1)
                LIndex1 = Mfxfld00to05.LastIndexOf(ChkIndex1)
                If FIndex1 = 1 And LIndex1 = 3 Then ' if date is in d/m/yy format
                    MfxfldDD = "0" & Mfxfld00to05.Substring(0, 1)
                    MfxfldMM = "0" & Mfxfld00to05.Substring(2, 1)
                    MfxldYY = Mfxfld00to05.Substring(4, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                    'ElseIf FIndex1 = -1 And LIndex1 = -1 Then ' if date in yyyymd format
                    '    MfxldYY = Mfxfld00to05.Substring(2, 2)
                    '    MfxfldMM = "0" & Mfxfld00to05.Substring(4, 1)
                    '    MfxfldDD = "0" & Mfxfld00to05.Substring(5, 1)
                    '    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                End If
            ElseIf Mfxfld00to05.Length > 10 Then 'Date is in Soul Format
                FIndex1 = Mfxfld00to05.IndexOf(ChkIndex1)
                LIndex1 = Mfxfld00to05.LastIndexOf(ChkIndex1)

                If FIndex1 = 1 And LIndex1 = 4 Then
                    MfxfldMM = "0" & Mfxfld00to05.Substring(0, 1)
                    MfxfldDD = Mfxfld00to05.Substring(2, 2)
                    MfxldYY = Mfxfld00to05.Substring(7, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 1 And LIndex1 = 3 Then
                    MfxfldMM = "0" & Mfxfld00to05.Substring(0, 1)
                    MfxfldDD = "0" & Mfxfld00to05.Substring(2, 1)
                    MfxldYY = Mfxfld00to05.Substring(6, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 2 And LIndex1 = 4 Then
                    MfxfldMM = Mfxfld00to05.Substring(0, 2)
                    MfxfldDD = "0" & Mfxfld00to05.Substring(3, 1)
                    MfxldYY = Mfxfld00to05.Substring(7, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 2 And LIndex1 = 5 Then
                    MfxfldMM = Mfxfld00to05.Substring(0, 2)
                    MfxfldDD = Mfxfld00to05.Substring(3, 2)
                    MfxldYY = Mfxfld00to05.Substring(8, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                End If
            Else 'CCF 022^a do not follow above Format then use Today date

                DDate = dtdate.Today
                Chkindex = DDate.IndexOf("/")
                If Chkindex <> -1 Then
                    ChkIndex1 = "/"
                Else
                    ChkIndex1 = "-"
                End If
                FIndex1 = DDate.IndexOf(ChkIndex1)
                LIndex1 = DDate.LastIndexOf(ChkIndex1)
                If FIndex1 = 1 And LIndex1 = 4 Then
                    MfxfldMM = "0" & DDate.Substring(0, 1)
                    MfxfldDD = DDate.Substring(2, 2)
                    MfxldYY = DDate.Substring(7, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                ElseIf FIndex1 = 1 And LIndex1 = 3 Then
                    MfxfldMM = "0" & DDate.Substring(0, 1)
                    MfxfldDD = "0" & DDate.Substring(2, 1)
                    MfxldYY = DDate.Substring(6, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD

                ElseIf FIndex1 = 2 And LIndex1 = 4 Then
                    MfxfldMM = DDate.Substring(0, 2)
                    MfxfldDD = "0" & DDate.Substring(3, 1)
                    MfxldYY = DDate.Substring(7, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD

                ElseIf FIndex1 = 2 And LIndex1 = 5 Then
                    MfxfldMM = DDate.Substring(0, 2)
                    MfxfldDD = DDate.Substring(3, 2)
                    MfxldYY = DDate.Substring(8, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                End If
            End If


        Else ' if CCF 022^a is not present then add Today date

            DDate = dtdate.Today
            Chkindex = DDate.IndexOf("/")
            If Chkindex <> -1 Then
                ChkIndex1 = "/"
            Else
                ChkIndex1 = "-"
            End If
            FIndex1 = DDate.IndexOf(ChkIndex1)
            LIndex1 = DDate.LastIndexOf(ChkIndex1)
            If FIndex1 = 1 And LIndex1 = 4 Then
                MfxfldMM = "0" & DDate.Substring(0, 1)
                MfxfldDD = DDate.Substring(2, 2)
                MfxldYY = DDate.Substring(7, 2)
                Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
            ElseIf FIndex1 = 1 And LIndex1 = 3 Then
                MfxfldMM = "0" & DDate.Substring(0, 1)
                MfxfldDD = "0" & DDate.Substring(2, 1)
                MfxldYY = DDate.Substring(6, 2)
                Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD

            ElseIf FIndex1 = 2 And LIndex1 = 4 Then
                MfxfldMM = DDate.Substring(0, 2)
                MfxfldDD = "0" & DDate.Substring(3, 1)
                MfxldYY = DDate.Substring(7, 2)
                Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
            Else
                If FIndex1 = 2 And LIndex1 = 5 Then
                    MfxfldMM = DDate.Substring(0, 2)
                    MfxfldDD = DDate.Substring(3, 2)
                    MfxldYY = DDate.Substring(8, 2)
                    Mfxfld0to5 = MfxldYY & MfxfldMM & MfxfldDD
                End If
            End If
        End If

    End Sub
    Private Function GetMfxfld18t21(ByRef M00818t21 As String, ByVal MFixFld18_21 As String)
        Select Case MFixFld18_21
            Case "ill"
                If M00818t21 Is Nothing Then
                    M00818t21 = "a"
                Else
                    M00818t21 = M00818t21 & "a"
                End If
            Case "map"
                If M00818t21 Is Nothing Then
                    M00818t21 = "b"
                Else
                    M00818t21 = M00818t21 & "b"
                End If
            Case "portrait"
                If M00818t21 Is Nothing Then
                    M00818t21 = "c"
                Else
                    M00818t21 = M00818t21 & "c"
                End If
            Case "chart"
                If M00818t21 Is Nothing Then
                    M00818t21 = "d"
                Else
                    M00818t21 = M00818t21 & "d"
                End If
            Case "plan"
                If M00818t21 Is Nothing Then
                    M00818t21 = "e"
                Else
                    M00818t21 = M00818t21 & "e"
                End If
            Case "plate"
                If M00818t21 Is Nothing Then
                    M00818t21 = "f"
                Else
                    M00818t21 = M00818t21 & "f"
                End If
            Case "music"
                If M00818t21 Is Nothing Then
                    M00818t21 = "g"
                Else
                    M00818t21 = M00818t21 & "g"
                End If
            Case "facsimile"
                If M00818t21 Is Nothing Then
                    M00818t21 = "h"
                Else
                    M00818t21 = M00818t21 & "h"
                End If
            Case "table"
                If M00818t21 Is Nothing Then
                    M00818t21 = "j"
                Else
                    M00818t21 = M00818t21 & "j"
                End If
            Case "||||"
                If M00818t21 Is Nothing Then
                    M00818t21 = "||||"
                End If
        End Select
    End Function

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
    Private Sub GetMaxRec()
        FolderLocation = Application.StartupPath & "\Data.csv"
        Dim RecId As String
        Dim BibRecIDDS As New Data.DataSet
        Dim i As Integer
        'Get Max Record ID from File 
        Dim strgetRecid As String = "SELECT Max(RecId) FROM " & FolderLocation & ""
        BibRecIDDS = DBcon.CreateDS(strgetRecid)
        'Get Maximum Record id from File
        Try
            'check for record id value,  if null then assgn 1 as a record id otherwise add 1 in existing maximum record id value
            If BibRecIDDS.Tables(0).Rows(0).IsNull(0) = True Then
                RecId = 1
            Else
                RecId = BibRecIDDS.Tables(0).Rows(0).Item(0)
                'FileOpen(2, Application.StartupPath & "\Data.csv", OpenMode.Binary) 'bad record is come then it is set in "c:\BadRecord\record.txt
            End If
        Catch ex As Exception
            'MsgBox(ex.ToString)
            RecId = 0
        End Try
        PMAX.Text = RecId
    End Sub
    Private Sub CCFtoMARC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GetMaxRec()
    End Sub

    Private Sub SaveBadCCFFileDialog_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveBadCCFFileDialog.FileOk
        BadFilePath = SaveBadCCFFileDialog.FileName
    End Sub
End Class
