-
josedavido.
User deleted
Para leer un texto de un documento .txt (Block de notas) y cargarlo a un ListBox, podemos utilizar una función muy sencilla como la siguiente:
Try
Dim SPath As String = ("C:\mitexto.txt") 'Ruta del Texto
Dim sContent As String = vbNullString
With My.Computer.FileSystem
' verifica si existe el path
If .FileExists(SPath) Then
ListBox1.Items.Clear()
Dim Archivo$ = SPath
Dim FF% = FreeFile()
FileOpen(FF, Archivo, OpenMode.Input)
Do While Not EOF(FF) 'Leerá lineas hasta que termine el archivo
ListBox1.Items.Add(LineInput(FF)) 'Agregara Linea Actual leida al ListBox (Lineinput es un sistema que lee linea por linea un archivo)
Loop
FileClose(FF)
Else
MsgBox("ruta inválida ke500", MsgBoxStyle.Critical, "error")
End If
End With
' errores
Catch ex As Exception
MsgBox(ex.Message.ToString, MsgBoxStyle.Critical)
End Try
Br,
Josedavido.