Search code examples
vb.netvb6

Remove Character from First Array and Last Array String


Dim arr() As String
Dim a As Integer
Dim temp As String
Dim temp2 As String

a = 0

Open App.Path & "\EndOfB.txt" For Input As #1

Do While Not EOF(1)

    Line Input #1, temp
    temp2 = temp2 & "," & temp
    a = a + 1
    arr = Split(temp2, ",")

Loop 
Close #1

Guys how can i remove the character (") in the first and last array? because if i write in a textfile, the first and last string had this character ("). This is the sample output".

"08:01:04 08:16:06 10:52:06 11:52:21"

Thanks in advance Guys. :)


Solution

  • Change your loop to

    Do While Not EOF(1)
    
        Line Input #1, temp
        temp2 = temp2 & "," & temp
        a = a + 1
        arr = Split(temp2, ",")
    
        ' Strip first character from first array element
        arr(LBound(arr)) = Right$(arr(LBound(arr)), Len(arr(LBound(arr)) - 1))
        ' Strip last  character from last array element
        arr(UBound(arr)) = Left$(arr(UBound(arr)), Len(arr(UBound(arr)) - 1))
    
    
    Loop