como genero un txt......
Pues eso, resulta que tengo unos datos y que quiero que se genere un archivo.txt, desde el programa de visual basic con esos datos.
Gracias.
Gracias.
Private Sub cmdGuardar_Click()
'Guardar
Dim i As Long
i = FreeFile
Open ARCHIVO For Output As i
Print #i, LINEA1
Print #i, LINEA2
Print #i, LINEA3
Close i
End Sub
Espero que esto te ayude
Rafa
'Guardar
Dim i As Long
i = FreeFile
Open ARCHIVO For Output As i
Print #i, LINEA1
Print #i, LINEA2
Print #i, LINEA3
Close i
End Sub
Espero que esto te ayude
Rafa
'Coloca esto en un modulo y a los botones has que llamen estos procedimientos espero te sirva de algo
Public filename As String
'****Cierra y guarda archivos*********
Sub CloseFile(filename As String)
Dim F As Integer
Dim cipher_text As String
Dim Arch_Texto As String
If filename = "" Or filename = " " Then Exit Sub
On Error GoTo save_Error
If Dir(filename) <> "" Then
response = MsgBox(("Ya existe el Archivo " & filename & " Desea Actualizar el expediente?"), vbYesNo + vbQuestion + vbDefaultButton2)
If response = vbNo Then Exit Sub
End If
F = FreeFile
Open filename For Output As F
Arch_Texto = frm_documento!Text1.Text & Chr(13) & frm_documento!Text3.Text
Print #F, Arch_Texto
Close F
frm_documento.Caption = "documento " + filename
Exit Sub
save_Error:
MsgBox "Ha ocurrido un error al intentar guardar el archivo.", 48
End Sub
'**** Abre los Archivos
Sub OpenFile(filename As String)
Dim F As Integer
Dim file_Texto As String
Dim Arch_Texto As String
If filename = "" Or filename = " " Then
MsgBox "Error Archivo no valido", vbInformation, APNotepad
End If
F = FreeFile
filename = "C:WINDOWSEscritorioayuda" & filename
Open filename For Input As F
archivo_texto = Input(LOF(F), F)
frm_documento!Text4.Text = archivo_texto
Close F
frm_documento.Caption = "Historial clinico " + filename
'End If
Exit Sub
etq_Error:
MsgBox "Ha ocurrido un error al intentar abrir el archivo.", 48, "APNotepad"
End Sub
Public filename As String
'****Cierra y guarda archivos*********
Sub CloseFile(filename As String)
Dim F As Integer
Dim cipher_text As String
Dim Arch_Texto As String
If filename = "" Or filename = " " Then Exit Sub
On Error GoTo save_Error
If Dir(filename) <> "" Then
response = MsgBox(("Ya existe el Archivo " & filename & " Desea Actualizar el expediente?"), vbYesNo + vbQuestion + vbDefaultButton2)
If response = vbNo Then Exit Sub
End If
F = FreeFile
Open filename For Output As F
Arch_Texto = frm_documento!Text1.Text & Chr(13) & frm_documento!Text3.Text
Print #F, Arch_Texto
Close F
frm_documento.Caption = "documento " + filename
Exit Sub
save_Error:
MsgBox "Ha ocurrido un error al intentar guardar el archivo.", 48
End Sub
'**** Abre los Archivos
Sub OpenFile(filename As String)
Dim F As Integer
Dim file_Texto As String
Dim Arch_Texto As String
If filename = "" Or filename = " " Then
MsgBox "Error Archivo no valido", vbInformation, APNotepad
End If
F = FreeFile
filename = "C:WINDOWSEscritorioayuda" & filename
Open filename For Input As F
archivo_texto = Input(LOF(F), F)
frm_documento!Text4.Text = archivo_texto
Close F
frm_documento.Caption = "Historial clinico " + filename
'End If
Exit Sub
etq_Error:
MsgBox "Ha ocurrido un error al intentar abrir el archivo.", 48, "APNotepad"
End Sub
