locked
Load a text field parser - fixed width RRS feed

  • Question

  • User696064841 posted

    I have this...  but I need to set the column widths based a variable... any ideas?

    Dim textParser As New FileIO.TextFieldParser(InFile)
    textParser.TextFieldType = FileIO.FieldType.FixedWidth
    Dim GetFieldLengths() As Integer = {27, 10, 13, 7, 4, 10, 10, 50, 50, 50, 50, 50, 33, 8, 18}
    textParser.FieldWidths = GetFieldLengths

    So I would like to do this... but ofcourse this will not work...

    If x = y then
    Dim GetFieldLengths() As Integer = {27, 10, 13, 7, 4, 10, 10, 50, 50, 50, 50, 50, 33, 8, 18}
    Else 
    Dim GetFieldLengths() As Integer = {27, 10, 13, 7, 4, 10, 10, 50, 50, 50, 50, 50, 33, 8, 99}
    End If
    textParser.FieldWidths = GetFieldLengths

    Thursday, August 30, 2012 4:04 PM

Answers

  • User696064841 posted

    This is what I did....  but I'm still open to suggestions...

    If Mid(sFileName, 1, 3) = "XXX" Then
    textParser.FieldWidths = GetProvCredit()
    End If
    
    Public Function GetProvCredit()
    Dim GetFieldLengths() As Integer = {27, 10, 13, 7, 4, 10, 10, 50, 50, 50, 50, 50, 33, 8, 18}
    Return GetFieldLengths
    End Function
    
    


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 30, 2012 4:23 PM