Visual Basic - Cargar un archivo .txt en un textbox

Life is soft - evento anual de software empresarial
 
Vista:

Cargar un archivo .txt en un textbox

Publicado por Andres M.Bottero (12 intervenciones) el 12/10/2003 00:18:40
Podrian pasarme un codigo fuente de que cuando haga click en un boton(command1), en un textbox(text1) me aparezca el texto de un archivo tipo .txt(c:\demo.txt) gracias a todos.
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:Cargar un archivo .txt en un textbox

Publicado por Cecilia Colalongo (3116 intervenciones) el 12/10/2003 13:08:24
Fijate con esto:

Text1.Text=FileToString("c:\demo.txt")

Public Function FileToString(FileName As String) As String
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

End Function

Y para el proceso inverso (si te sirve)

StringToFile Text1.Text,"c:\demo.txt"

Public Function StringToFile(StringText As String, FileName As String) As Long
Dim hlngFile As Long

hlngFile = FreeFile

Open FileName For Binary Access Write As hlngFile

Put hlngFile, , StringText

Close hlngFile

StringToFile = FileLen(FileName)

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