Private Sub btnTranslate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTranslate.Click

        Dim oEdiDoc As ediDocument
        Dim oSchema As ediSchema
        Dim oSchemas As ediSchemas
        Dim oSegment As ediDataSegment
        Dim sSegmentID As String = ""
        Dim nArea As Integer = 0
        Dim sValue As String = ""
        Dim sLoopDesc As String = ""
        Dim sN1EntityIdfr As String = ""
        Dim sEdiFileName As String = ""
        Dim sSefFileName As String = ""

        Dim sPath As String = AppDomain.CurrentDomain.BaseDirectory

        ' Create the top-level application object "ediDocument". 
        oEdiDoc = New ediDocument

        ' This makes certain that Framework EDI only uses the SEF file provided,
        ' and that it does not use its built-in Standard Reference table to translate
        ' the EDI document
        oSchemas = oEdiDoc.GetSchemas
        oSchemas.EnableStandardReference = False

        ' The FORWARD-ONLY cursor increases the performance of processing the EDI
        ' document (see Technical Note 3 below).
        oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly
        sEdiFileName = "944_004010.X12"
        sSefFileName = "944_004010.EVAL0.SEF"   'evaluation SEF files

        ' Specify SEF file to load. 
        oSchema = oEdiDoc.LoadSchema(sPath + sSefFileName, SchemaTypeIDConstants.Schema_Standard_Exchange_Format)

        ' Specify EDI document to read. 
        oEdiDoc.LoadEdi(sPath + sEdiFileName)

        ' Gets the first data segment in the EDI document. 
        oSegment = oEdiDoc.FirstDataSegment

        ' Loop that will traverse through the EDI document from top to bottom. This
        ' is required for FORWARD-ONLY cursor.
        Do While Not oSegment Is Nothing

            ' Data segments are uniquely identified by their segment Identifier (ID).
            ' The loop section and the area (or table) properties of the data segment
            ' are read for each iteration of the loop. 
            sSegmentID = oSegment.ID
            sLoopDesc = oSegment.LoopSection
            nArea = oSegment.Area

            If nArea = 0 Then

                ' Data segments that are not designated an area (i.e. area = 0) are control
                ' segments that are part of the Interchange or Functional Group envelopes,
                ' and are not part of the Transaction Set.

                If sSegmentID = "ISA" Then
                    sValue = oSegment.DataElementValue(1)       ' Authorization Information Qualifier (I01) 
                    sValue = oSegment.DataElementValue(2)       ' Authorization Information (I02) 
                    sValue = oSegment.DataElementValue(3)       ' Security Information Qualifier (I03) 
                    sValue = oSegment.DataElementValue(4)       ' Security Information (I04) 
                    sValue = oSegment.DataElementValue(5)       ' Interchange ID Qualifier (I05) 
                    sValue = oSegment.DataElementValue(6)       ' Interchange Sender ID (I06) 
                    sValue = oSegment.DataElementValue(7)       ' Interchange ID Qualifier (I05) 
                    sValue = oSegment.DataElementValue(8)       ' Interchange Receiver ID (I07) 
                    sValue = oSegment.DataElementValue(9)       ' Interchange Date (I08) 
                    sValue = oSegment.DataElementValue(10)      ' Interchange Time (I09) 
                    sValue = oSegment.DataElementValue(11)      ' Interchange Control Standards Identifier (I10) 
                    ListBox1.Items.Add(oSegment.DataElementValue(12))      ' Interchange Control Version Number (I11) 
                    sValue = oSegment.DataElementValue(13)      ' Interchange Control Number (I12) 
                    sValue = oSegment.DataElementValue(14)      ' Acknowledgment Requested (I13) 
                    sValue = oSegment.DataElementValue(15)      ' Usage Indicator (I14) 
                    sValue = oSegment.DataElementValue(16)      ' Component Element Separator (I15) 

                ElseIf sSegmentID = "IEA" Then
                    sValue = oSegment.DataElementValue(1)       ' Number of Included Functional Groups (I16) 
                    sValue = oSegment.DataElementValue(2)       ' Interchange Control Number (I12) 

                ElseIf sSegmentID = "GS" Then
                    sValue = oSegment.DataElementValue(1)       ' Functional Identifier Code (479) 
                    sValue = oSegment.DataElementValue(2)       ' Application Sender's Code (142) 
                    sValue = oSegment.DataElementValue(3)       ' Application Receiver's Code (124) 
                    sValue = oSegment.DataElementValue(4)       ' Date (373) 
                    sValue = oSegment.DataElementValue(5)       ' Time (337) 
                    ListBox1.Items.Add(oSegment.DataElementValue(6))       ' Group Control Number (28) 
                    sValue = oSegment.DataElementValue(7)       ' Responsible Agency Code (455) 
                    sValue = oSegment.DataElementValue(8)       ' Version / Release / Industry Identifier Code (480) 

                ElseIf sSegmentID = "GE" Then
                    sValue = oSegment.DataElementValue(1)       ' Number of Transaction Sets Included (97) 
                    sValue = oSegment.DataElementValue(2)       ' Group Control Number (28) 

                End If      ' sSegmentID = "GE" 

            ElseIf nArea = 1 Then

                ' Data segments in area 1 are processed here.

                If sLoopDesc = "" Then

                    If sSegmentID = "ST" Then       ' Transaction Set Header 
                        sValue = oSegment.DataElementValue(1)       ' Transaction Set Identifier Code (143) 
                        ListBox1.Items.Add(oSegment.DataElementValue(2))       ' Transaction Set Control Number (329) 

                    ElseIf sSegmentID = "W17" Then      ' Warehouse Receipt Identification 
                        sValue = oSegment.DataElementValue(1)       ' Reporting Code (514) 
                        sValue = oSegment.DataElementValue(2)       ' Date (373) 
                        ListBox1.Items.Add(oSegment.DataElementValue(3))       ' Warehouse Receipt Number (394) 
                        sValue = oSegment.DataElementValue(4)       ' Depositor Order Number (285) 
                        sValue = oSegment.DataElementValue(5)       ' Shipment Identification Number (145) 
                        sValue = oSegment.DataElementValue(6)       ' Time Qualifier (176) 
                        sValue = oSegment.DataElementValue(7)       ' Time (337) 
                        sValue = oSegment.DataElementValue(8)       ' Master Reference (Link) Number (474) 
                        sValue = oSegment.DataElementValue(9)       ' Link Sequence Number (472) 

                    ElseIf sSegmentID = "N9" Then       ' Reference Identification 
                        sValue = oSegment.DataElementValue(1)       ' Reference Identification Qualifier (128) 
                        ListBox1.Items.Add(oSegment.DataElementValue(2))       ' Reference Identification (127) 
                        sValue = oSegment.DataElementValue(3)       ' Free-form Description (369) 
                        sValue = oSegment.DataElementValue(4)       ' Date (373) 
                        sValue = oSegment.DataElementValue(5)       ' Time (337) 
                        sValue = oSegment.DataElementValue(6)       ' Time Code (623) 
                        sValue = oSegment.DataElementValue(7, 1)        ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(7, 2)        ' Reference Identification (127) 
                        sValue = oSegment.DataElementValue(7, 3)        ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(7, 4)        ' Reference Identification (127) 
                        sValue = oSegment.DataElementValue(7, 5)        ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(7, 6)        ' Reference Identification (127) 
                    End If

                ElseIf sLoopDesc = "N1" Then
                    If sSegmentID = "N1" Then
                        sN1EntityIdfr = oSegment.DataElementValue(1)

                    End If

                    If sN1EntityIdfr = "DE" Then    'DEPOSITOR

                        If sSegmentID = "N1" Then       ' Name 
                            sValue = oSegment.DataElementValue(1)       ' Entity Identifier Code (98) 
                            ListBox1.Items.Add("Depositor Name: " + oSegment.DataElementValue(2))       ' Name (93) 
                            sValue = oSegment.DataElementValue(3)       ' Identification Code Qualifier (66) 
                            ListBox1.Items.Add(oSegment.DataElementValue(4))       ' Identification Code (67) 
                            sValue = oSegment.DataElementValue(5)       ' Entity Relationship Code (706) 
                            sValue = oSegment.DataElementValue(6)       ' Entity Identifier Code (98) 

                        ElseIf sSegmentID = "N2" Then       ' Additional Name Information 
                            sValue = oSegment.DataElementValue(1)       ' Name (93) 
                            sValue = oSegment.DataElementValue(2)       ' Name (93) 

                        ElseIf sSegmentID = "N3" Then       ' Address Information 
                            sValue = oSegment.DataElementValue(1)       ' Address Information (166) 
                            sValue = oSegment.DataElementValue(2)       ' Address Information (166) 

                        ElseIf sSegmentID = "N4" Then       ' Geographic Location 
                            sValue = oSegment.DataElementValue(1)       ' City Name (19) 
                            sValue = oSegment.DataElementValue(2)       ' State or Province Code (156) 
                            sValue = oSegment.DataElementValue(3)       ' Postal Code (116) 
                            sValue = oSegment.DataElementValue(4)       ' Country Code (26) 
                            sValue = oSegment.DataElementValue(5)       ' Location Qualifier (309) 
                            sValue = oSegment.DataElementValue(6)       ' Location Identifier (310) 
                        End If

                    ElseIf sN1EntityIdfr = "WH" Then  'WAREHOUSE

                        If sSegmentID = "N1" Then       ' Name 
                            sValue = oSegment.DataElementValue(1)       ' Entity Identifier Code (98) 
                            ListBox1.Items.Add("Warehouse name: " + oSegment.DataElementValue(2))       ' Name (93) 
                            sValue = oSegment.DataElementValue(3)       ' Identification Code Qualifier (66) 
                            ListBox1.Items.Add(oSegment.DataElementValue(4))       ' Identification Code (67) 
                            sValue = oSegment.DataElementValue(5)       ' Entity Relationship Code (706) 
                            sValue = oSegment.DataElementValue(6)       ' Entity Identifier Code (98) 

                        ElseIf sSegmentID = "N2" Then       ' Additional Name Information 
                            sValue = oSegment.DataElementValue(1)       ' Name (93) 
                            sValue = oSegment.DataElementValue(2)       ' Name (93) 

                        ElseIf sSegmentID = "N3" Then       ' Address Information 
                            sValue = oSegment.DataElementValue(1)       ' Address Information (166) 
                            sValue = oSegment.DataElementValue(2)       ' Address Information (166) 

                        ElseIf sSegmentID = "N4" Then       ' Geographic Location 
                            sValue = oSegment.DataElementValue(1)       ' City Name (19) 
                            sValue = oSegment.DataElementValue(2)       ' State or Province Code (156) 
                            sValue = oSegment.DataElementValue(3)       ' Postal Code (116) 
                            sValue = oSegment.DataElementValue(4)       ' Country Code (26) 
                            sValue = oSegment.DataElementValue(5)       ' Location Qualifier (309) 
                            sValue = oSegment.DataElementValue(6)       ' Location Identifier (310) 
                        End If

                    End If

                End If      ' sLoopDesc = "N1" 

            ElseIf nArea = 2 Then

                ' Data segments in area 2 are processed here.

                If sLoopDesc = "" Then

                    ' Nothing to do. 

                ElseIf sLoopDesc = "W07" Then

                    If sSegmentID = "W07" Then      ' Item Detail For Stock Receipt 
                        ListBox1.Items.Add(oSegment.DataElementValue(1))       ' Quantity Received (413) 
                        ListBox1.Items.Add(oSegment.DataElementValue(2))       ' Unit or Basis for Measurement Code (355) 
                        ListBox1.Items.Add(oSegment.DataElementValue(3))       ' U.P.C. Case Code (438) 
                        sValue = oSegment.DataElementValue(4)       ' Product/Service ID Qualifier (235) 
                        sValue = oSegment.DataElementValue(5)       ' Product/Service ID (234) 
                        sValue = oSegment.DataElementValue(6)       ' Product/Service ID Qualifier (235) 
                        sValue = oSegment.DataElementValue(7)       ' Product/Service ID (234) 
                        sValue = oSegment.DataElementValue(8)       ' Warehouse Lot Number (451) 
                        sValue = oSegment.DataElementValue(9)       ' Warehouse Detail Adjustment Identifier (893) 
                        sValue = oSegment.DataElementValue(10)      ' Product/Service ID Qualifier (235) 
                        sValue = oSegment.DataElementValue(11)      ' Product/Service ID (234) 

                    ElseIf sSegmentID = "G69" Then      ' Line Item Detail - Description 
                        sValue = oSegment.DataElementValue(1)       ' Free-form Description (369) 

                    ElseIf sSegmentID = "N9" Then       ' Reference Identification 
                        sValue = oSegment.DataElementValue(1)       ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(2)       ' Reference Identification (127) 
                        sValue = oSegment.DataElementValue(3)       ' Free-form Description (369) 
                        sValue = oSegment.DataElementValue(4)       ' Date (373) 
                        sValue = oSegment.DataElementValue(5)       ' Time (337) 
                        sValue = oSegment.DataElementValue(6)       ' Time Code (623) 
                        sValue = oSegment.DataElementValue(7, 1)        ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(7, 2)        ' Reference Identification (127) 
                        sValue = oSegment.DataElementValue(7, 3)        ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(7, 4)        ' Reference Identification (127) 
                        sValue = oSegment.DataElementValue(7, 5)        ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(7, 6)        ' Reference Identification (127) 

                    ElseIf sSegmentID = "W20" Then      ' Line-Item Detail - Miscellaneous 
                        sValue = oSegment.DataElementValue(1)       ' Pack (356) 
                        sValue = oSegment.DataElementValue(2)       ' Size (357) 
                        sValue = oSegment.DataElementValue(3)       ' Unit or Basis for Measurement Code (355) 
                        ListBox1.Items.Add(oSegment.DataElementValue(4))       ' Weight (81) 
                        ListBox1.Items.Add(oSegment.DataElementValue(5))       ' Weight Qualifier (187) 
                        ListBox1.Items.Add(oSegment.DataElementValue(6))       ' Weight Unit Code (188) 
                        sValue = oSegment.DataElementValue(7)       ' Unit Weight (395) 
                        sValue = oSegment.DataElementValue(8)       ' Volume (183) 
                        sValue = oSegment.DataElementValue(9)       ' Unit or Basis for Measurement Code (355) 
                        sValue = oSegment.DataElementValue(10)      ' Color (397) 

                    End If      ' sSegmentID = "W20" 

                ElseIf sLoopDesc = "W07;W13" Then

                    If sSegmentID = "W13" Then      ' Item Detail Exception 
                        ListBox1.Items.Add(oSegment.DataElementValue(1))       ' Quantity (380) 
                        sValue = oSegment.DataElementValue(2)       ' Unit or Basis for Measurement Code (355) 
                        sValue = oSegment.DataElementValue(3)       ' Receiving Condition Code (412) 
                        sValue = oSegment.DataElementValue(4)       ' Warehouse Lot Number (451) 
                        sValue = oSegment.DataElementValue(5)       ' Damage Reason Code (853) 

                    ElseIf sSegmentID = "N9" Then       ' Reference Identification 
                        sValue = oSegment.DataElementValue(1)       ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(2)       ' Reference Identification (127) 
                        sValue = oSegment.DataElementValue(3)       ' Free-form Description (369) 
                        sValue = oSegment.DataElementValue(4)       ' Date (373) 
                        sValue = oSegment.DataElementValue(5)       ' Time (337) 
                        sValue = oSegment.DataElementValue(6)       ' Time Code (623) 
                        sValue = oSegment.DataElementValue(7, 1)        ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(7, 2)        ' Reference Identification (127) 
                        sValue = oSegment.DataElementValue(7, 3)        ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(7, 4)        ' Reference Identification (127) 
                        sValue = oSegment.DataElementValue(7, 5)        ' Reference Identification Qualifier (128) 
                        sValue = oSegment.DataElementValue(7, 6)        ' Reference Identification (127) 

                    End If      ' sSegmentID = "N9" 

                End If      ' sLoopDesc = "W07;W13" 

            ElseIf nArea = 3 Then

                ' Data segments in area 3 are processed here.

                If sLoopDesc = "" Then

                    If sSegmentID = "W14" Then      ' Total Receipt Information 
                        ListBox1.Items.Add(oSegment.DataElementValue(1))       ' Quantity Received (413) 
                        sValue = oSegment.DataElementValue(2)       ' Number of Units Shipped (382) 
                        sValue = oSegment.DataElementValue(3)       ' Quantity Damaged/On Hold (452) 
                        sValue = oSegment.DataElementValue(4)       ' Lading Quantity Received (414) 
                        sValue = oSegment.DataElementValue(5)       ' Lading Quantity (80) 

                    ElseIf sSegmentID = "SE" Then       ' Transaction Set Trailer 
                        sValue = oSegment.DataElementValue(1)       ' Number of Included Segments (96) 
                        sValue = oSegment.DataElementValue(2)       ' Transaction Set Control Number (329) 

                    End If      ' sSegmentID = "SE" 

                End If      ' sLoopDesc = "" 

            End If      ' nArea = 3 

            ' Get the next data segment in the document. 
            ediDataSegment.Set(oSegment, oSegment.Next)

        Loop        ' Not oSegment Is Nothing 

        MessageBox.Show("Done")

        oSchema.Dispose()
        oSchemas.Dispose()
        oEdiDoc.Dispose()
    

    Click here to download a trial version of the Framework EDI