-
when the program writes to the text file, the data continues to be written horizontally instead of writing to a newline.
here's the code i am using:
Open App.Path & "\data.txt" For Append As #1
For i = 0 To 8
Write #1, txtField(i).Text,
Next i
Close #1
eg: data.txt
"132456","R.","Kelly","1","2","3","4","5","6","987654","Michael","Jordan","6","5","4","3","2","1",et c..
want:
"132456","R.","Kelly","1","2","3","4","5","6" (without comma at the end)
"987654","Michael","Jordan","6","5","4","3","2","1"
etc..
would anyone know how to make it move to newline?
thanks.
-
When using write() I don't think you will be able to create a new line, since write() doesn't support this.
You would therefore have to swicth to another way of writing to the file.
If you just want this structure you could write:
dim strTmp as string
dim i as byte
Open App.path & "\data.txt" for Append as #1
For i=0 to 8
strTmp = chr(34) & txtField(i).Text & Chr(34) & chr(44)
Next i
strTmp = Left(StrTmp, len(StrTmp)-1) & chr(13) & chr(10)
Print #1, strTmp
Close #1
I think this should do it, however I havn't tested it.
-
o.k
o.k i'll give it a try.
thanks. :)
-
Surely you can just do this? :o
Code:
Open App.Path & "\data.txt" For Append As #1
For i = 0 To 8
Write #1, txtField(i).Text & vbCrLf,
Next i
Close #1
-
I only ever use output like follows :
Code:
Print #1, something
if thats of any help ;)
-
o.k thanks guys.
o.k here are the outputs.
AIS_DK: your method writes the last piece of information and two new lines.
"(txtField(8).text"
_
_
m0rph: your method writes the information then a newline and in my text boxes there are funny looking squares on the end of the fields.
"(txtField(1).text
","(txtField(2).text
","(txtField(3).text
","(txtField(4).text
plenderj: i might play around with Print #1 too.
thanks guys... :(
-
Ok my mistake, I wasn't near my computer with VB on, so here is little fix up.
Print ofcourse terminates any string that you write with a new line, so the correct code should be:
dim strTmp as string
dim i as byte
Open App.path & "\data.txt" for Append as #1
For i=0 to 8
strTmp = strTmp & chr(34) & txtField(i).Text & Chr(34) & chr(44)
Next i
strTmp = Left(StrTmp, len(StrTmp)-1)
Print #1, strTmp
strTmp = ""
Close #1
See if that should not fix it
BTW. Funny looking Squares are mearly characters, that either has no visual "face" or can't be shown by the program you use. IE. If your text reader doesn't interpret TAB, then the program would display the "character" TAB with a square.
-
Dont be sad you maggot, just use Print ;)
Code:
Dim i As Long
For i = 0 to txtField.Count -1
Print #1, txtField(i).Text
Next i
-
maybe instead of VBCRLF, just use either VBCR or VBLF.
(Try both, not sure which would do it)
-
thanks
thanks guys for your help, most of the help posted produced what i wanted in the end.
thanks. :D