Public Class cEDI Shared Function getValueReplaced(s) As String Return s.Replace("|plus|", "+").Replace("|dppkt|", ":").Replace("|pkt|", ".") End Function Shared Function getSimpleLine(codeToReplace, lines(), Optional defaultValue = "", Optional replaceValues = True) As String For Each l In lines If l.StartsWith(codeToReplace) Then If replaceValues Then l = l.Replace("|plus|", "+").Replace("|dppkt|", ":").Replace("|pkt|", ".") Return l.Replace(codeToReplace, "") End If Next Return defaultValue End Function Shared Function getSimpleLineNumber(codeToReplace, lines()) As Integer Dim cnt = 0 For Each l In lines If l.StartsWith(codeToReplace) Then Return cnt cnt += 1 Next Return -1 End Function Shared Function getSEGMENT(lines(), segCode, segEnd) As String() Dim cnt = 0 Dim SEG2 As New List(Of String) '= Nothing Dim goAndAdd As Boolean = False For Each l In lines If l.ToString.StartsWith(segCode) Then goAndAdd = True End If If goAndAdd Then SEG2.Add(l) : cnt += 1 'getSEGMENT(lines, "UNS+D", "UNS+"), "CST+") If segEnd <> "" And (l.ToString.StartsWith(segEnd) And Not l.ToString.StartsWith(segCode)) Then 'neues segment; Die Trennung ist noch, wenn der Startsegment-Code nochmal vorkommt! Exit For End If Next Return SEG2.ToArray() End Function Shared Function SpltSEGMENT(lines(), splitcode) As List(Of String()) SpltSEGMENT = New List(Of String()) Dim SplitSEG As New List(Of String) ' Dim cnt = 0 For Each l In lines If l.ToString.StartsWith(splitcode) Then If SplitSEG IsNot Nothing Then SpltSEGMENT.Add(SplitSEG.ToArray) SplitSEG.Clear() End If If SplitSEG IsNot Nothing Then SplitSEG.Add(l) Next If SplitSEG.Count > 0 Then SpltSEGMENT.Add(SplitSEG.ToArray) 'letztes End Function Shared Function getValuesFromLine(line) As String() If line.trim = "" Then Return {} Return line.split("+") End Function Shared Function getSubValues(s) As String() If s.trim = "" Then Return {} Return s.split(":") End Function Shared Function isValidDateElseNothing(o) As Object If o IsNot Nothing Then If IsDate(o) Then If o > "01.01.1990" Then Return CDate(o) End If End If End If Return Nothing End Function Shared Function isLeerNothingDbl(o) If o Is Nothing Then Return Nothing ElseIf IsNumeric(o) Then Return CDbl(o) Else Return Nothing End If End Function Shared Function isLeerNothingDblPunktKomma(o) If o Is Nothing Then Return Nothing ElseIf IsNumeric(o) Then Return CDbl(o.replace(".", ",")) Else Return Nothing End If End Function End Class