Visual Basic - Archivos de Texto

Life is soft - evento anual de software empresarial
 
Vista:

Archivos de Texto

Publicado por mARCELO (46 intervenciones) el 02/11/2005 14:21:28
Tengo la sig. rutina:
Private Sub Command1_Click()
'Generar archivo de texto'
Dim fs, X
Set fs = CreateObject("Scripting.FileSystemObject")
Set X = fs.CreateTextFile("C:\escribiendo.txt", True)
X.WriteLine ("Resultados Programa de Optimización")
Dim a(10), b(10) As Variant
For i = 1 To 10 Step 1
a(i) = 2
b(i) = 5 * a(i)
X.WriteLine (a(i))
X.WriteLine (b(i))
Next i
End Sub

Lo que quiero es que a(i) y b(i) se escriban en una sola línea del archivo de texto pero no he podido hacerlo. En Esta rutina me aparecen en lineas diferentes.
He tratado con comas, puntos y comas pero no me ha resultado nada de esto.
Agradeceré cualquier ayuda o sugerencia.
Agracdeecidon como siempre
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:Archivos de Texto

Publicado por jose carlos (340 intervenciones) el 02/11/2005 17:25:58
PRUEBA ESTO, SI FUNCIONA

Private Sub Command2_Click()
Open "C:\PPP.TXT" For Output As #1
Dim a(10), b(10) As Variant
For i = 1 To 10 Step 1
a(i) = 2
b(i) = 5 * a(i)
Print #1, Str((a(i)));
Print #1, Str((b(i)))
Next i
Close #1
End Sub

SI DESPUÉS DE PRINT #1, STR((A(I))); AÑADES "-"; O SUSTITUIR EL - POR EL SÍMBOLO QUE QUIERAS, SERÁ UN CHIVATO PARA PODER CAPTURAR DESPUES CADA VALOR

TE SEPARARÁ LOS DATOS CON UN GUION O EL VALOR QUE LE HAYAS DADO

PARA LEER LOS DATOS CAMBIA OUTPUT POR INPUT Y PRINT #1 POR INPUT #1, SI EL VALOR QUE PONES DE SEPARACIÓN ES UNA COMA ENTONCES SERÍA LINE INPUT #1

SALUDOS


TAMBIÉN PUEDES SUPRIMIR LOS STR
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