Visual Basic - LEER UN ARCHIVO DE TEXTO

Life is soft - evento anual de software empresarial
 
Vista:

LEER UN ARCHIVO DE TEXTO

Publicado por BENJAS (18 intervenciones) el 04/03/2004 19:00:27
AYUDA POR FAVOR, ya referencie a "Microsoft scripting Runtime"
e hice esto:

dim lineaALeer as string
dim fso As FileSystemObject
dim txt As TextStream
dim archivo As File
set archivo = fso.getfile(c:\archivo.txt)
archivo.OpenAsTextStream
Set txt = archivo.OpenAsTextStream(ForReading)
lineaALeer = txt.readline & vbCrLf

pero me aparece el error:OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET,
GRACIAS ME URGE
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:LEER UN ARCHIVO DE TEXTO

Publicado por ADRIANA (4 intervenciones) el 04/03/2004 19:08:08
No te metas en problemas, prueba ésto:
Usa un listbox, alli se va a ver la info del archivo de texto

dim linea as string
open "c:\mi archivo.txt" for input as #1

do while not eof(1)

line input#1, linea
list1.additem linea

loop

close #1
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:LEER UN ARCHIVO DE TEXTO

Publicado por Cecilia Colalongo (3116 intervenciones) el 04/03/2004 19:20:46
Fijate con ésta función:

Dim Archivo As String

Archivo = FileToString("c:\archivo.txt")

Public Function FileToString(FileName As String) As String
On Error GoTo ErrorHandler
Dim hlngFile As Long, strFile As String
hlngFile = FreeFile
Open FileName For Binary Access Read As hlngFile
FileToString = vbNullString
strFile = String(FileLen(FileName), \" \")
Get hlngFile, , strFile
Close hlngFile
FileToString = strFile
Exit Function
ErrorHandler:
FileToString = Empty
End Function
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar