Haber si alguien me puede ayudar con este codigo
El código se encarga de generar un txt plano a partir de otro archivo de texto plano, sustitullendo "," por salto de linea y retorno de carro para dejarlo todo en una columna. El problema es q se pierden unos 100.000 registros en el proceso y no encuentro la razon. Un saludo y gracias por adelantado.
ifile = 1
Open "c:log1.txt" For Append As #ifile
Print #ifile, RichTextBox3.Text
Close #ifile
strLogFile = "c:Log2.txt"
ifile = 1
Open strLogFile For Append As #ifile
medio = 0
inicio = 1
'fin = 600000
x = 1
primeravez = 1
longitud = Len(RichTextBox4.Text)
While inicio <= longitud
fin = 10000
If Mid(RichTextBox4.Text, inicio + fin, 1) <> "," Then
For x = 1 To 20
If Mid(RichTextBox4.Text, inicio + fin - x, 1) = "," Then
fin = fin - x
x = 20
End If
Next x
End If
RichTextBox1.Text = Mid(RichTextBox4.Text, inicio, fin - 1)
'MsgBox Mid(RichTextBox4.Text, inicio + fin, 1)
RichTextBox1.Text = Replace(RichTextBox1.Text, Chr(13), "")
RichTextBox1.Text = Replace(RichTextBox1.Text, Chr(32), "")
RichTextBox1.Text = Replace(RichTextBox1.Text, Chr(10), "")
RichTextBox1.Text = Replace(RichTextBox1.Text, ";", "")
RichTextBox1.Text = Replace(RichTextBox1.Text, "}", "")
RichTextBox1.Text = Replace(RichTextBox1.Text, ",", Chr(13) & Chr(10))
Print #ifile, RichTextBox1.Text
RichTextBox1.Text = ""
If primeravez = 1 Then
inicio = fin + 1
medio = fin
Else
medio = medio + fin
inicio = medio + 1
End If
Wend
Imanol Rivas
ifile = 1
Open "c:log1.txt" For Append As #ifile
Print #ifile, RichTextBox3.Text
Close #ifile
strLogFile = "c:Log2.txt"
ifile = 1
Open strLogFile For Append As #ifile
medio = 0
inicio = 1
'fin = 600000
x = 1
primeravez = 1
longitud = Len(RichTextBox4.Text)
While inicio <= longitud
fin = 10000
If Mid(RichTextBox4.Text, inicio + fin, 1) <> "," Then
For x = 1 To 20
If Mid(RichTextBox4.Text, inicio + fin - x, 1) = "," Then
fin = fin - x
x = 20
End If
Next x
End If
RichTextBox1.Text = Mid(RichTextBox4.Text, inicio, fin - 1)
'MsgBox Mid(RichTextBox4.Text, inicio + fin, 1)
RichTextBox1.Text = Replace(RichTextBox1.Text, Chr(13), "")
RichTextBox1.Text = Replace(RichTextBox1.Text, Chr(32), "")
RichTextBox1.Text = Replace(RichTextBox1.Text, Chr(10), "")
RichTextBox1.Text = Replace(RichTextBox1.Text, ";", "")
RichTextBox1.Text = Replace(RichTextBox1.Text, "}", "")
RichTextBox1.Text = Replace(RichTextBox1.Text, ",", Chr(13) & Chr(10))
Print #ifile, RichTextBox1.Text
RichTextBox1.Text = ""
If primeravez = 1 Then
inicio = fin + 1
medio = fin
Else
medio = medio + fin
inicio = medio + 1
End If
Wend
Imanol Rivas