Hola, necesito que cuando mi form se cargue se abra un archivo txt en un TextBox y que cuando pulse algún boton se guarde.
He encontrado los siguientes códigos, pero no se como aplicarlos:
ABRIR:
Código:
Sub AbrirArchivo(Ruta As String, Texto As TextBox)
Dim fnum As Integer
On Error GoTo Ninguno
fnum = FreeFile
Open Ruta For Input As fnum
Do While Not EOF(fnum)
Line Input #fnum, txt
Texto.Text = Texto.Text & vbCrLf & txt
Loop
Close fnum
Ninguno:
End Sub
CERRAR:
Código:
Sub GuardarArchivo(Ruta As String, Texto As TextBox)
Dim fnum As Integer
On Error GoTo Ninguno
fnum = FreeFile
Open Ruta For Output As fnum
Print #fnum, Texto.Text
Close fnum
Exit sub
Ninguno:
Msgbox “Error al guardar el archivo”
End Sub
Utilizo VB.Net
Muchas gracias
Editado:
(El tema es que no se donde poner cada parte del código.....)