Protected Sub btnStartAck_Click(sender As Object, e As EventArgs) Handles btnStartAck.Click

        Dim oEdidoc As ediDocument = Nothing
        Dim oSchemas As ediSchemas = Nothing
        Dim oSegment As ediDataSegment = Nothing
        Dim oAck As ediAcknowledgment = Nothing

        Dim sPath As String = AppDomain.CurrentDomain.BaseDirectory

        'Instantiate edi document object
        ediDocument.Set(oEdiDoc, New ediDocument)

        'oEdiDoc = New ediDocument

        'Set cursor type to forward only to save RAM memory
        oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly

        'disable internal standard reference library
        ediSchemas.Set(oSchemas, oEdiDoc.GetSchemas)
        oSchemas.EnableStandardReference = False

        'load sef file when needed
        oSchemas.Option(SchemasOptionIDConstants.OptSchemas_SetOnDemand) = 1

        oEdidoc.LoadSchema(sPath & "files\997_004010.SEF", SchemaTypeIDConstants.Schema_Standard_Exchange_Format)
        oEdidoc.LoadSchema(sPath & "files\837_X098A1_SemRef.SEF", SchemaTypeIDConstants.Schema_Standard_Exchange_Format)

        Dim sEdiString As String
        Dim sAckString As String

        'instantiate acknowledgment document
        ediAcknowledgment.Set(oAck, oEdidoc.GetAcknowledgment)

        'enable 997 and TA1 acknowledgment
        oAck.EnableFunctionalAcknowledgment = True
        oAck.EnableInterchangeAcknowledgment = True

        sEdiString = Trim(txtEdiString.Text)

        'load edi string
        oEdidoc.LoadEdiString(sEdiString)

        'Iterate thru all segments of EDI File so that they can be validated
        ediDataSegment.Set(oSegment, oEdidoc.FirstDataSegment)
        Do While Not oSegment Is Nothing
            ediDataSegment.Set(oSegment, oSegment.Next)
        Loop

        'save acknowledgment to a string variable
        sAckString = oAck.GetEdiString
        txtAckString.Text = sAckString

    End Sub