Hi folks. I'm having some problem here. I have a list of files to read and have to append them all to one unique file. the problem is that when i open the first file to read. I read the first line and discard it. when i read the second line, its empty ! but it is not in the original file. what im doing wrong ? tks for the help

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGera.Click
        Dim QtdPapeis As Integer
        Dim I As Integer
        Dim oWrite As System.IO.StreamWriter
        Dim oRead As System.IO.StreamReader
        Dim caminho As String

        oWrite = IO.File.CreateText("c:\ibov\carga.txt")
        QtdPapeis = PF.SecurityCount() - 1
        For I = 0 To QtdPapeis
            caminho = "c:\ibov\" & PF.Security(I).GetSymbol & ".txt"
            oRead = New System.IO.StreamReader(caminho)
            GeraCargaTabelaQuotes(oRead, oWrite)
    End Sub

Public Sub GeraCargaTabelaQuotes(ByVal arq_origem As System.IO.StreamReader, ByVal arq_destino As System.IO.StreamWriter)
        Dim linhaAtual, linhaescrever, cod, desc, periodo, data, hora, open, high, low, close, volume, interest As String
        Dim strArray() As String
        linhaAtual = arq_origem.ReadLine() 'pula a 1a linha
        linhaAtual = arq_origem.ReadLine()
        While (Not arq_origem.EndOfStream)
            strArray = linhaAtual.Split(",")
            cod = strArray(1)
            desc = strArray(2)
            periodo = strArray(3)
            data = strArray(4).Substring(0, 4) & "-" & strArray(4).Substring(4, 2) & "-" & strArray(4).Substring(6, 2)
            hora = strArray(5)
            open = strArray(6)
            high = strArray(7)
            low = strArray(8)
            close = strArray(9)
            volume = strArray(10)
            interest = strArray(11)
            linhaescrever = cod & ";" & desc & ";" & periodo & ";" & data & ";" & hora & ";" & open & ";" & high & ";" & low & ";" & close & ";" & volume & ";" & interest
            linhaAtual = arq_origem.ReadLine()
        End While

    End Sub
5 Years
Discussion Span
Last Post by gmadeira

it seams that is something to do with the file im using. i tried with other file and worked. do you figure out whats going on ?

content of the file that worked:
line 1
line 2

content of the file that is not working:
TGMA3,TEGMA ON,D,20070703,000000,20.14018,20.83202,20.14018,20.37079,2538500,3722

the second line returns empty !


I found out that each line is terminated by a "?". how can I do VB understand that this is my end of line ?

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.