maya18 de Enero del 2004
Preguntaquiero guardar en archivo el texto incluido dentro de una serie de textbox.
he utilizado un commonddialog y me crea el archivo pero no me guarda ninguna informacion dentro.
el codigo es el siguiente:
Private Sub Command2_Click()
CommonDialog2.Filter = "Archivos de Texto (*.txt)|*.txt" ' ABRE VENTANA PARA los datos (SOLO LECTURA)
CommonDialog2.FilterIndex = 1
CommonDialog2.ShowSave
If CommonDialog2.FileName = "" Then
Exit Sub 'SI NO HAY datos NO CARGA NADA
Else ' cargamos el archivo
ruta = CommonDialog2.FileName
Set fso = CreateObject("Scripting.FileSystemObject")
Set ofich = fso.createtextfile(ruta) 'abre el fichero seleccionado para su lectura
For fila = 0 To n - 1
ofich.writeline = Text2(fila).Text
ofich.writeline = Text3(fila).Text
Next
End If
ofich.Close ' cerramos el objeto
End Sub
¿que hago mal? porque no me graba nada... ademas, si el archivo ya existe y lo quiero sobre escribir me da error.
Gracias
Salu2
he utilizado un commonddialog y me crea el archivo pero no me guarda ninguna informacion dentro.
el codigo es el siguiente:
Private Sub Command2_Click()
CommonDialog2.Filter = "Archivos de Texto (*.txt)|*.txt" ' ABRE VENTANA PARA los datos (SOLO LECTURA)
CommonDialog2.FilterIndex = 1
CommonDialog2.ShowSave
If CommonDialog2.FileName = "" Then
Exit Sub 'SI NO HAY datos NO CARGA NADA
Else ' cargamos el archivo
ruta = CommonDialog2.FileName
Set fso = CreateObject("Scripting.FileSystemObject")
Set ofich = fso.createtextfile(ruta) 'abre el fichero seleccionado para su lectura
For fila = 0 To n - 1
ofich.writeline = Text2(fila).Text
ofich.writeline = Text3(fila).Text
Next
End If
ofich.Close ' cerramos el objeto
End Sub
¿que hago mal? porque no me graba nada... ademas, si el archivo ya existe y lo quiero sobre escribir me da error.
Gracias
Salu2
