Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
        Dim oEdiDoc As ediDocument
        Dim oSchema As ediSchema
        Dim oSchemas As ediSchemas
        Dim oInterchange As ediInterchange
        Dim oGroup As ediGroup
        Dim oTransactionSet As ediTransactionSet
        Dim oSegment As ediDataSegment
        Dim sEdiFileName As String
        Dim sSefFileName As String
        Dim sPath As String

        sPath = 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 generate
        ' the EDI document
        oSchemas = oEdiDoc.GetSchemas
        oSchemas.EnableStandardReference = False

        ' The FORWARD-WRITE cursor increases the performance of processing the EDI
        ' document (see Technical Note 3 below).
        oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardWrite

        oEdiDoc.Property(DocumentPropertyIDConstants.Property_DocumentBufferIO) = 200

        ' Terminators have to be specified. 
        oEdiDoc.SegmentTerminator = "~{13:10}"
        oEdiDoc.ElementTerminator = "*"
        oEdiDoc.CompositeTerminator = "!"

        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)

        ' Creates the Interchange Control Header segment (ISA). 
        oInterchange = oEdiDoc.CreateInterchange("X", "004010")
        oSegment = oInterchange.GetDataSegmentHeader
        oSegment.DataElementValue(1) = "00"         ' Authorization Information Qualifier (I01) 
        oSegment.DataElementValue(2) = "          "         ' Authorization Information (I02) 
        oSegment.DataElementValue(3) = "00"         ' Security Information Qualifier (I03) 
        oSegment.DataElementValue(4) = "          "         ' Security Information (I04) 
        oSegment.DataElementValue(5) = "ZZ"         ' Interchange ID Qualifier (I05) 
        oSegment.DataElementValue(6) = "SENDER ID      "        ' Interchange Sender ID (I06) 
        oSegment.DataElementValue(7) = "ZZ"         ' Interchange ID Qualifier (I05) 
        oSegment.DataElementValue(8) = "RECEIVER ID    "        ' Interchange Receiver ID (I07) 
        oSegment.DataElementValue(9) = "140817"         ' Interchange Date (I08) 
        oSegment.DataElementValue(10) = "0917"      ' Interchange Time (I09) 
        oSegment.DataElementValue(11) = "U"         ' Interchange Control Standards Identifier (I10) 
        oSegment.DataElementValue(12) = "00401"         ' Interchange Control Version Number (I11) 
        oSegment.DataElementValue(13) = "000000001"         ' Interchange Control Number (I12) 
        oSegment.DataElementValue(14) = "0"         ' Acknowledgment Requested (I13) 
        oSegment.DataElementValue(15) = "T"         ' Usage Indicator (I14) 
        oSegment.DataElementValue(16) = "!"         ' Component Element Separator (I15) 

        ' Creates the Functional Group Header segment (GS). 
        oGroup = oInterchange.CreateGroup("004010")
        oSegment = oGroup.GetDataSegmentHeader
        oSegment.DataElementValue(1) = "RE"         ' Functional Identifier Code (479) 
        oSegment.DataElementValue(2) = "SENDER ID"         ' Application Sender's Code (142) 
        oSegment.DataElementValue(3) = "RECEIVER ID"       ' Application Receiver's Code (124) 
        oSegment.DataElementValue(4) = "20140817"       ' Date (373) 
        oSegment.DataElementValue(5) = "091700"       ' Time (337) 
        oSegment.DataElementValue(6) = "1"      ' Group Control Number (28) 
        oSegment.DataElementValue(7) = "X"      ' Responsible Agency Code (455) 
        oSegment.DataElementValue(8) = "004010"         ' Version / Release / Industry Identifier Code (480) 

        ' TRANSACTION SET ID 944 - Warehouse Stock Transfer Receipt Advice  

        ' Creates the Transaction Set header segment (ST). 
        oTransactionSet = oGroup.CreateTransactionSet("944")
        oSegment = oTransactionSet.GetDataSegmentHeader
        oSegment.DataElementValue(1) = "944"        ' Transaction Set Identifier Code (143) 
        oSegment.DataElementValue(2) = "0001"       ' Transaction Set Control Number (329) 


        ' Warehouse Receipt Identification (W17) 
        oSegment = oTransactionSet.CreateDataSegment("W17")
        oSegment.DataElementValue(1) = "F"      ' Reporting Code (514) 
        oSegment.DataElementValue(2) = "20140817"       ' Date (373) 
        oSegment.DataElementValue(3) = "WarehouseReceiptNo"         ' Warehouse Receipt Number (394) 
        oSegment.DataElementValue(4) = "LOL OrderNo"         ' Depositor Order Number (285) 
        'oSegment.DataElementValue(5) = ""         ' Shipment Identification Number (145) 
        'oSegment.DataElementValue(6) = ""      ' Time Qualifier (176) 
        'oSegment.DataElementValue(7) = ""       ' Time (337) 
        'oSegment.DataElementValue(8) = ""         ' Master Reference (Link) Number (474) 
        'oSegment.DataElementValue(9) = ""         ' Link Sequence Number (472) 

        ' Name (N1) DEPOSITOR
        oSegment = oTransactionSet.CreateDataSegment("N1\N1")
        oSegment.DataElementValue(1) = "DE"         ' Entity Identifier Code (98) 
        oSegment.DataElementValue(2) = "DepositorName"        ' Name (93) 
        oSegment.DataElementValue(3) = "9"      ' Identification Code Qualifier (66) 
        oSegment.DataElementValue(4) = "DepositorDUNS+4No"         ' Identification Code (67) 

        ' Name (N1) WAREHOUSE
        oSegment = oTransactionSet.CreateDataSegment("N1\N1")
        oSegment.DataElementValue(1) = "WH"         ' Entity Identifier Code (98) 
        oSegment.DataElementValue(2) = "WarehouseName"        ' Name (93) 
        oSegment.DataElementValue(3) = "6"      ' Identification Code Qualifier (66) 
        oSegment.DataElementValue(4) = "WarehousePlantCode"         ' Identification Code (67) 

        ' Reference Identification (N9) 
        ediDataSegment.Set(oSegment, oTransactionSet.CreateDataSegment("N9"))
        oSegment.DataElementValue(1) = "LO"         ' Reference Identification Qualifier (128) 
        oSegment.DataElementValue(2) = "LoadPlanningNo"         ' Reference Identification (127) 

        Dim nItem As Integer = 0

        While nItem < 1
            ' Item Detail For Stock Receipt (W07) 
            oSegment = oTransactionSet.CreateDataSegment("W07\W07")
            oSegment.DataElementValue(1) = "123"        ' Quantity Received (413) 
            oSegment.DataElementValue(2) = "EA"         ' Unit or Basis for Measurement Code (355) 
            oSegment.DataElementValue(3) = "UPC CaseCode"       ' U.P.C. Case Code (438) 
            oSegment.DataElementValue(4) = "SW"         ' Product/Service ID Qualifier (235) 
            oSegment.DataElementValue(5) = "StockNo"         ' Product/Service ID (234) 
            oSegment.DataElementValue(6) = "LT"         ' Product/Service ID Qualifier (235) 
            oSegment.DataElementValue(7) = "LOLLotNo"         ' Product/Service ID (234) 
            oSegment.DataElementValue(8) = "WarehouseLotNO"         ' Warehouse Lot Number (451) 
            'oSegment.DataElementValue(9) = ""      ' Warehouse Detail Adjustment Identifier (893) 
            oSegment.DataElementValue(10) = "ZZ"        ' Product/Service ID Qualifier (235) 
            oSegment.DataElementValue(11) = "O"        ' Product/Service ID (234) 

            ' Line-Item Detail - Miscellaneous (W20) 
            ediDataSegment.Set(oSegment, oTransactionSet.CreateDataSegment("W07\W20"))
            'oSegment.DataElementValue(1) = ""         ' Pack (356) 
            'oSegment.DataElementValue(2) = ""       ' Size (357) 
            'oSegment.DataElementValue(3) = ""         ' Unit or Basis for Measurement Code (355) 
            oSegment.DataElementValue(4) = "123.12"         ' Weight (81) 
            oSegment.DataElementValue(5) = "N"      ' Weight Qualifier (187) 
            oSegment.DataElementValue(6) = "L"      ' Weight Unit Code (188)

            Dim nItemException As Integer = 0

            While nItemException < 1
                ' Item Detail Exception (W13) 
                oSegment = oTransactionSet.CreateDataSegment("W07\W13\W13")
                oSegment.DataElementValue(1) = "1"         ' Quantity (380) 
                oSegment.DataElementValue(2) = "EA"         ' Unit or Basis for Measurement Code (355) 
                oSegment.DataElementValue(3) = "02"         ' Receiving Condition Code (412) 

                nItemException = nItemException + 1
            End While

            nItem = nItem + 1
        End While 'nItem

        ' Total Receipt Information (W14) 
        oSegment = oTransactionSet.CreateDataSegment("W14")
        oSegment.DataElementValue(1) = "123"        ' Quantity Received (413) 
        'oSegment.DataElementValue(2) = ""         ' Number of Units Shipped (382) 
        'oSegment.DataElementValue(3) = ""      ' Quantity Damaged/On Hold (452) 
        'oSegment.DataElementValue(4) = ""        ' Lading Quantity Received (414) 
        'oSegment.DataElementValue(5) = ""        ' Lading Quantity (80) 


        ' Trailing segments are automatically created when Framework EDI commits
        ' (saves) the instance of "oEdiDoc" object into an EDI file.
        oEdiDoc.Save(sPath + sEdiFileName)

        MessageBox.Show(oEdiDoc.GetEdiString())

        oSegment.Dispose()
        oTransactionSet.Dispose()
        oGroup.Dispose()
        oInterchange.Dispose()
        oSchema.Dispose()
        oSchemas.Dispose()
        oEdiDoc.Dispose()
    

    Click here to download a trial version of the Framework EDI