how can i do this? ive been trying all day, and i cant figure it out.
some help please?
-Presise
Printable View
how can i do this? ive been trying all day, and i cant figure it out.
some help please?
-Presise
VB Code:
Open "c:\temp\test.txt" For Output As #1 Print "line1" Print "line2" Close #1 'AND/OR Open "c:\temp\test.txt" For Append As #1 Print "line3" Print "line4" Close #1
The difference between the two is Output erases whats in the file (if the file exists) and writes it. Otherwise it creates the file then writes it.
Append also creates the file if it does not exist, but instead of erasing the contents of the file when it does exist, it continues to write. And Rhinobull, it goes like this. In bold is where I corrected you:
VB Code:
Open "c:\temp\test.txt" For Output As #1 Print [b]#1,[/b] "line1" Print [b]#1,[/b] "line2" Close #1 'AND/OR Open "c:\temp\test.txt" For Append As #1 Print [b]#1,[/b] "line3" Print [b]#1,[/b] "line4" Close #1
VB Code:
Open "c:\temp\test.txt" For Output As #1 Print #1, "line1"; Print #1, "line2"; Close #1 'AND/OR Open "c:\temp\test.txt" For Append As #1 Print #1, "line3"; Print #1, "line4"; Close #1
so it doesnt add vbcrlfs ;)
thanks, but exactly how would i use this?
[edit] nvm, i figured it out. thank you.
Hello PresiseFA,
you can also use Write insted of Print
VB Code:
Print #1,,"Hello","resiseFA" Write #1,"Hello","resiseFA"
inside the text file you will have two rows:
the first row will look like this:
Hello resiseFA
the second row will look like this:
"Hello","resiseFA"
also with Print and Write you can put the result of a matematic calc like:
VB Code:
Print #1,2*3; Write #1,2*3;
inside the text file you will see the result of 2*3 (6)
Best Regards,
ERAN
P.S: Try to read more on the MSDN how to read and write to a file in a RANDOM Order
small example:
VB Code:
Private Type myStracture iID As Integer sLastName As String * 40 sFirstName As String * 20 End Type dim EmpRecord as myStracture EmpRecord.iID = "12345" EmpRecord.sLastName = "Fox" EmpRecord.sFirstName = "Eran" Open "C:\MyFile.txt for Random As #1 Len = Len(EmpRecord) Put #1,EmpRecord 'write on record to the file Get #1,1,EmpRecorde 'get the 1st Record in the file Seek #1,4 ' go to the 4th Record in the file
Good Luck
ERAN
Here, i hope it helpsQuote:
Originally Posted by PresiseFA
Edit: Saw above too late.
Hey I remember you, XeonTeam. It's been awhile.
Oh, yes of course - result of a freehand typing. Thanks.Quote:
Originally Posted by Jacob Roman
thanks for the help, all of you. but this was for a bug report system in my game. i had to set it up to record the players name, and the bug they reported, so its like:
"Test reported: the chat doesnt work"
=) it works fine now tho..