Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'This is just an example program to show how to translate an EDI X12 130 Student Educational Record Transcript 'in VB.NET with Framework EDI Dim oEdiDoc As ediDocument Dim oSchema As ediSchema Dim oSchemas As ediSchemas Dim oSegment As ediDataSegment Dim sSegmentID As String Dim sLoopSection As String Dim nArea As Integer Dim sValue As String Dim sN1LoopQlfr As String Dim sQlfr As String Dim sSefFile As String = "130_4010.SEF" Dim sEdiFile As String = "130.x12" Dim sPath As String = AppDomain.CurrentDomain.BaseDirectory 'CREATES EDIDOC OBJECT ediDocument.Set(oEdiDoc, New ediDocument) 'THIS MAKES CERTAIN THAT FREDI ONLY USES THE SEF FILE PROVIDED, AND THAT IT DOES 'NOT USE ITS BUILT-IN STANDARD REFERENCE TABLE TO TRANSLATE THE EDI FILE. ediSchemas.Set(oSchemas, oEdiDoc.GetSchemas) oSchemas.EnableStandardReference = False 'THIS OPTIONS STOPS FREDI FROM KEEPING ALL THE SEGMENTS IN MEMORY oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly 'LOADS THE SEF FILE ediSchema.Set(oSchema, oEdiDoc.ImportSchema(sPath + sSefFile, 0)) 'LOADS THE EDI FILE oEdiDoc.LoadEdi(sPath + sEdiFile) 'GETS THE FIRST DATA SEGMENT ediDataSegment.Set(oSegment, oEdiDoc.FirstDataSegment) 'LOOP THAT WILL TRAVERSE THRU EDI FILE FROM TOP TO BOTTOM Do While Not oSegment Is Nothing 'DATA SEGMENTS WILL BE IDENTIFIED BY THEIR ID, THE LOOP SECTION AND AREA '(OR TABLE) NUMBER THAT THEY ARE IN. sSegmentID = oSegment.ID sLoopSection = oSegment.LoopSection nArea = oSegment.Area If nArea = 0 Then If sLoopSection = "" Then If sSegmentID = "ISA" Then sValue = oSegment.DataElementValue(1) 'Authorization Information Qualifier sValue = oSegment.DataElementValue(2) 'Authorization Information sValue = oSegment.DataElementValue(3) 'Security Information Qualifier sValue = oSegment.DataElementValue(4) 'Security Information sValue = oSegment.DataElementValue(5) 'Interchange ID Qualifier sValue = oSegment.DataElementValue(6) 'Interchange Sender ID sValue = oSegment.DataElementValue(7) 'Interchange ID Qualifier sValue = oSegment.DataElementValue(8) 'Interchange Receiver ID sValue = oSegment.DataElementValue(9) 'Interchange Date sValue = oSegment.DataElementValue(10) 'Interchange Time sValue = oSegment.DataElementValue(11) 'Interchange Control Standards Identifier sValue = oSegment.DataElementValue(12) 'Interchange Control Version Number ListBox1.Items.Add(oSegment.DataElement(13).Description + " = " + oSegment.DataElementValue(13)) 'Interchange Control Number sValue = oSegment.DataElementValue(14) 'Acknowledgment Requested sValue = oSegment.DataElementValue(15) 'Usage Indicator sValue = oSegment.DataElementValue(16) 'Component Element Separator ElseIf sSegmentID = "GS" Then sValue = oSegment.DataElementValue(1) 'Functional Identifier Code sValue = oSegment.DataElementValue(2) 'Application Sender's Code sValue = oSegment.DataElementValue(3) 'Application Receiver's Code sValue = oSegment.DataElementValue(4) 'Date sValue = oSegment.DataElementValue(5) 'Time ListBox1.Items.Add(oSegment.DataElement(6).Description + " = " + oSegment.DataElementValue(6)) 'Group Control Number sValue = oSegment.DataElementValue(7) 'Responsible Agency Code sValue = oSegment.DataElementValue(8) 'Version / Release / Industry Identifier Code End If 'sSegmentID End If 'sLoopSection ElseIf nArea = 1 Then If sLoopSection = "" Then If sSegmentID = "ST" Then sValue = oSegment.DataElementValue(1) 'Transaction Set Identifier Code ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Transaction Set Control Number ElseIf sSegmentID = "BGN" Then sValue = oSegment.DataElementValue(1) 'Transaction Set Purpose Code ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Reference Identification ListBox1.Items.Add(oSegment.DataElement(3).Description + " = " + oSegment.DataElementValue(3)) 'Date sValue = oSegment.DataElementValue(4) 'Time sValue = oSegment.DataElementValue(5) 'Time Code ElseIf sSegmentID = "ERP" Then sValue = oSegment.DataElementValue(1) 'Transaction Type Code sValue = oSegment.DataElementValue(2) 'Status Reason Code ElseIf sSegmentID = "REF" Then sValue = oSegment.DataElementValue(1) 'Reference Identification Qualifier ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Reference Identification ElseIf sSegmentID = "DMG" Then sValue = oSegment.DataElementValue(1) 'Date Time Period Format Qualifier sValue = oSegment.DataElementValue(2) 'Date Time Period sValue = oSegment.DataElementValue(3) 'Gender Code sValue = oSegment.DataElementValue(4) 'Marital Status Code sValue = oSegment.DataElementValue(5) 'Race or Ethnicity Code sValue = oSegment.DataElementValue(6) 'Citizenship Status Code ElseIf sSegmentID = "PCL" Then sValue = oSegment.DataElementValue(1) 'Identification Code Qualifier sValue = oSegment.DataElementValue(2) 'Identification Code sValue = oSegment.DataElementValue(3) 'Date Time Period Format Qualifier sValue = oSegment.DataElementValue(4) 'Date Time Period sValue = oSegment.DataElementValue(5) 'Academic Degree Code sValue = oSegment.DataElementValue(6) 'Date Time Period sValue = oSegment.DataElementValue(7) 'Description End If 'Segment ID ElseIf sLoopSection = "N1" Then If sSegmentID = "N1" Then sN1LoopQlfr = oSegment.DataElementValue(1) End If If sN1LoopQlfr = "AS" Then 'Post Secondary Education Sender If sSegmentID = "N1" Then ListBox1.Items.Add(oSegment.DataElement(2).Description + " Sender = " + oSegment.DataElementValue(2)) 'Name ListBox1.Items.Add(oSegment.DataElement(4).Description + " = " + oSegment.DataElementValue(4)) 'Identification Code ElseIf sSegmentID = "N3" Then ListBox1.Items.Add(oSegment.DataElement(1).Description + " = " + oSegment.DataElementValue(1)) 'Address Information ElseIf sSegmentID = "N4" Then ListBox1.Items.Add(oSegment.DataElement(1).Description + " = " + oSegment.DataElementValue(1)) 'City Name ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'State or Province Code ListBox1.Items.Add(oSegment.DataElement(3).Description + " = " + oSegment.DataElementValue(3)) 'Postal Code End If 'Segment ID ElseIf sN1LoopQlfr = "AT" Then 'Post Secondary Education Receiver If sSegmentID = "N1" Then ListBox1.Items.Add(oSegment.DataElement(2).Description + " Receiver = " + oSegment.DataElementValue(2)) 'Name ListBox1.Items.Add(oSegment.DataElement(4).Description + " = " + oSegment.DataElementValue(4)) 'Identification Code ElseIf sSegmentID = "N3" Then ListBox1.Items.Add(oSegment.DataElement(1).Description + " = " + oSegment.DataElementValue(1)) 'Address Information ElseIf sSegmentID = "N4" Then ListBox1.Items.Add(oSegment.DataElement(1).Description + " = " + oSegment.DataElementValue(1)) 'City Name ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'State or Province Code ListBox1.Items.Add(oSegment.DataElement(3).Description + " = " + oSegment.DataElementValue(3)) 'Postal Code End If 'Segment ID End If 'sN1LoopQlfr ElseIf sLoopSection = "IN1" Then If sSegmentID = "IN1" Then sValue = oSegment.DataElementValue(1) 'Entity Type Qualifier sValue = oSegment.DataElementValue(2) 'Name Type Code sValue = oSegment.DataElementValue(3) 'Entity Identifier Code sValue = oSegment.DataElementValue(4) 'Reference Identification Qualifier sValue = oSegment.DataElementValue(5) 'Reference Identification sValue = oSegment.DataElementValue(6) 'Individual Relationship Code sValue = oSegment.DataElementValue(7) 'Level of Individual, Test, or Course Code ElseIf sSegmentID = "IN2" Then sQlfr = oSegment.DataElementValue(1) If sQlfr = "05" Then ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Name ElseIf sQlfr = "02" Then ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Name ElseIf sQlfr = "15" Then ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Name End If End If 'Segment ID ElseIf sLoopSection = "SST" Then If sSegmentID = "SST" Then sValue = oSegment.DataElementValue(1) 'Status Reason Code ElseIf sSegmentID = "N1" Then sQlfr = oSegment.DataElementValue(1) 'Entity Identifier Code If sQlfr = "HS" Then ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Name ListBox1.Items.Add(oSegment.DataElement(4).Description + " = " + oSegment.DataElementValue(4)) 'Identification Code End If End If 'Segment ID ElseIf sLoopSection = "TST" Then If sSegmentID = "TST" Then sValue = oSegment.DataElementValue(1) 'Educational Test or Requirement Code ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Name sValue = oSegment.DataElementValue(3) 'Date Time Period Format Qualifier sValue = oSegment.DataElementValue(4) 'Date Time Period sValue = oSegment.DataElementValue(5) 'Reference Identification sValue = oSegment.DataElementValue(6) 'Reference Identification sValue = oSegment.DataElementValue(7) 'Level of Individual, Test, or Course Code sValue = oSegment.DataElementValue(8) 'Level of Individual, Test, or Course Code sValue = oSegment.DataElementValue(9) 'Date Time Period sValue = oSegment.DataElementValue(10) 'Test Norm Type Code sValue = oSegment.DataElementValue(11) 'Test Norming Period Code sValue = oSegment.DataElementValue(12) 'Language Code sValue = oSegment.DataElementValue(13) 'Date Time Period sValue = oSegment.DataElementValue(14) 'Yes/No Condition or Response Code sValue = oSegment.DataElementValue(15) 'Yes/No Condition or Response Code End If 'sSegmentID End If 'sLoopSection ElseIf nArea = 2 Then If sLoopSection = "LX" Then If sSegmentID = "LX" Then sValue = oSegment.DataElementValue(1) 'Assigned Number ElseIf sSegmentID = "HS" Then sValue = oSegment.DataElementValue(1) 'Health Screening Type Code sValue = oSegment.DataElementValue(2) 'Date Time Period Format Qualifier sValue = oSegment.DataElementValue(3) 'Date Time Period sValue = oSegment.DataElementValue(4) 'Status Reason Code ElseIf sSegmentID = "IMM" Then sValue = oSegment.DataElementValue(1) 'Immunization Type Code sValue = oSegment.DataElementValue(2) 'Date Time Period Format Qualifier sValue = oSegment.DataElementValue(3) 'Date Time Period sValue = oSegment.DataElementValue(4) 'Immunization Status Code sValue = oSegment.DataElementValue(5) 'Report Type Code End If 'Segment ID ElseIf sLoopSection = "LX;HC" Then If sSegmentID = "HC" Then sValue = oSegment.DataElementValue(1) 'Disease Condition Type Code sValue = oSegment.DataElementValue(2) 'Medical Treatment Type Code sValue = oSegment.DataElementValue(3) 'Date Time Period Format Qualifier sValue = oSegment.DataElementValue(4) 'Date Time Period sValue = oSegment.DataElementValue(5) 'Yes/No Condition or Response Code ElseIf sSegmentID = "N1" Then sValue = oSegment.DataElementValue(1) 'Entity Identifier Code sValue = oSegment.DataElementValue(2) 'Name sValue = oSegment.DataElementValue(3) 'Identification Code Qualifier sValue = oSegment.DataElementValue(4) 'Identification Code sValue = oSegment.DataElementValue(5) 'Entity Relationship Code sValue = oSegment.DataElementValue(6) 'Entity Identifier Code ElseIf sSegmentID = "N2" Then sValue = oSegment.DataElementValue(1) 'Name sValue = oSegment.DataElementValue(2) 'Name ElseIf sSegmentID = "PER" Then sValue = oSegment.DataElementValue(1) 'Contact Function Code sValue = oSegment.DataElementValue(2) 'Name sValue = oSegment.DataElementValue(3) 'Communication Number Qualifier sValue = oSegment.DataElementValue(4) 'Communication Number sValue = oSegment.DataElementValue(5) 'Communication Number Qualifier sValue = oSegment.DataElementValue(6) 'Communication Number sValue = oSegment.DataElementValue(7) 'Communication Number Qualifier sValue = oSegment.DataElementValue(8) 'Communication Number sValue = oSegment.DataElementValue(9) 'Contact Inquiry Reference ElseIf sSegmentID = "N3" Then sValue = oSegment.DataElementValue(1) 'Address Information sValue = oSegment.DataElementValue(2) 'Address Information ElseIf sSegmentID = "N4" Then sValue = oSegment.DataElementValue(1) 'City Name sValue = oSegment.DataElementValue(2) 'State or Province Code sValue = oSegment.DataElementValue(3) 'Postal Code sValue = oSegment.DataElementValue(4) 'Country Code sValue = oSegment.DataElementValue(5) 'Location Qualifier sValue = oSegment.DataElementValue(6) 'Location Identifier End If 'Segment ID ElseIf sLoopSection = "LX;SES" Then If sSegmentID = "SES" Then sValue = oSegment.DataElementValue(1) 'Date Time Period sValue = oSegment.DataElementValue(2) 'Count sValue = oSegment.DataElementValue(3) 'Date Time Period sValue = oSegment.DataElementValue(4) 'Session Code ListBox1.Items.Add(oSegment.DataElement(5).Description + " = " + oSegment.DataElementValue(5)) 'Name sValue = oSegment.DataElementValue(6) 'Date Time Period Format Qualifier sValue = oSegment.DataElementValue(7) 'Date Time Period sValue = oSegment.DataElementValue(8) 'Date Time Period Format Qualifier sValue = oSegment.DataElementValue(9) 'Date Time Period sValue = oSegment.DataElementValue(10) 'Level of Individual, Test, or Course Code sValue = oSegment.DataElementValue(11) 'Identification Code Qualifier sValue = oSegment.DataElementValue(12) 'Identification Code sValue = oSegment.DataElementValue(13) 'Name sValue = oSegment.DataElementValue(14) 'Status Reason Code ElseIf sSegmentID = "SSE" Then sValue = oSegment.DataElementValue(1) 'Date ElseIf sSegmentID = "NTE" Then sValue = oSegment.DataElementValue(1) 'Note Reference Code ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Description ElseIf sSegmentID = "N1" Then sValue = oSegment.DataElementValue(1) 'Entity Identifier Code ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Name sValue = oSegment.DataElementValue(3) 'Identification Code Qualifier sValue = oSegment.DataElementValue(4) 'Identification Code ElseIf sSegmentID = "N3" Then sValue = oSegment.DataElementValue(1) 'Address Information ElseIf sSegmentID = "N4" Then sValue = oSegment.DataElementValue(1) 'City Name sValue = oSegment.DataElementValue(2) 'State or Province Code sValue = oSegment.DataElementValue(3) 'Postal Code End If 'Segment ID ElseIf sLoopSection = "LX;SES;SUM" Then If sSegmentID = "SUM" Then sValue = oSegment.DataElementValue(1) 'Academic Credit Type Code sValue = oSegment.DataElementValue(2) 'Academic Grade or Course Level Code sValue = oSegment.DataElementValue(3) 'Yes/No Condition or Response Code sValue = oSegment.DataElementValue(4) 'Quantity sValue = oSegment.DataElementValue(5) 'Quantity sValue = oSegment.DataElementValue(6) 'Quantity sValue = oSegment.DataElementValue(7) 'Range Minimum sValue = oSegment.DataElementValue(8) 'Range Maximum sValue = oSegment.DataElementValue(9) 'Academic Grade Point Average sValue = oSegment.DataElementValue(10) 'Yes/No Condition or Response Code sValue = oSegment.DataElementValue(11) 'Class Rank sValue = oSegment.DataElementValue(12) 'Quantity End If 'Segment ID ElseIf sLoopSection = "LX;SES;CRS" Then If sSegmentID = "CRS" Then sValue = oSegment.DataElementValue(1) 'Basis for Academic Credit Code sValue = oSegment.DataElementValue(2) 'Academic Credit Type Code sValue = oSegment.DataElementValue(3) 'Quantity sValue = oSegment.DataElementValue(4) 'Quantity sValue = oSegment.DataElementValue(5) 'Academic Grade Qualifier sValue = oSegment.DataElementValue(6) 'Academic Grade sValue = oSegment.DataElementValue(7) 'Yes/No Condition or Response Code sValue = oSegment.DataElementValue(8) 'Academic Grade or Course Level Code sValue = oSegment.DataElementValue(9) 'Course Repeat or No Count Indicator Code sValue = oSegment.DataElementValue(10) 'Identification Code Qualifier sValue = oSegment.DataElementValue(11) 'Identification Code sValue = oSegment.DataElementValue(12) 'Quantity sValue = oSegment.DataElementValue(13) 'Level of Individual, Test, or Course Code sValue = oSegment.DataElementValue(14) 'Name ListBox1.Items.Add(oSegment.DataElement(15).Description + " = " + oSegment.DataElementValue(15)) 'Reference Identification sValue = oSegment.DataElementValue(16) 'Name ElseIf sSegmentID = "NTE" Then sValue = oSegment.DataElementValue(1) 'Note Reference Code ListBox1.Items.Add(oSegment.DataElement(2).Description + " = " + oSegment.DataElementValue(2)) 'Description End If 'Segment ID ElseIf sLoopSection = "LX;SES;CRS;MKS" Then If sSegmentID = "MKS" Then sValue = oSegment.DataElementValue(1) 'Mark Code Type sValue = oSegment.DataElementValue(2) 'Academic Grade Qualifier sValue = oSegment.DataElementValue(3) 'Academic Grade End If 'Segment ID ElseIf sLoopSection = "LX;SES;DEG" Then If sSegmentID = "DEG" Then sValue = oSegment.DataElementValue(1) 'Academic Degree Code sValue = oSegment.DataElementValue(2) 'Date Time Period Format Qualifier sValue = oSegment.DataElementValue(3) 'Date Time Period sValue = oSegment.DataElementValue(4) 'Description ElseIf sSegmentID = "FOS" Then sValue = oSegment.DataElementValue(1) 'Academic Field of Study Level or Type Code sValue = oSegment.DataElementValue(2) 'Identification Code Qualifier sValue = oSegment.DataElementValue(3) 'Identification Code sValue = oSegment.DataElementValue(4) 'Description ElseIf sSegmentID = "NTE" Then sValue = oSegment.DataElementValue(1) 'Note Reference Code sValue = oSegment.DataElementValue(2) 'Description End If 'sSegmentID End If 'sLoopSection End If 'nArea 'GETS THE NEXT DATA SEGMENT ediDataSegment.Set(oSegment, oSegment.Next) Loop 'DESTROY OBJECTS oSchema.Dispose() oSchemas.Dispose() oEdiDoc.Dispose() End Sub