Aug 18th, 2005, 12:28 PM
#1
Thread Starter
New Member
write to text file
how can i do this? ive been trying all day, and i cant figure it out.
some help please?
-Presise
Aug 18th, 2005, 12:30 PM
#2
Re: write to text file
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
Aug 18th, 2005, 12:37 PM
#3
Re: write to text file
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
Aug 18th, 2005, 12:54 PM
#4
Re: write to text file
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
Aug 18th, 2005, 12:54 PM
#5
Thread Starter
New Member
Re: write to text file
thanks, but exactly how would i use this?
[edit] nvm, i figured it out. thank you.
Last edited by PresiseFA; Aug 18th, 2005 at 01:18 PM .
Aug 18th, 2005, 01:19 PM
#6
Hyperactive Member
Re: write to text file
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
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
Aug 18th, 2005, 01:22 PM
#7
Lively Member
Re: write to text file
Originally Posted by
PresiseFA
thanks, but exactly how would i use this?
[edit] nvm, i figured it out. thank you.
Here, i hope it helps
Edit: Saw above too late.
Attached Files
Normality is what you make it.
Aug 18th, 2005, 01:35 PM
#8
Re: write to text file
Hey I remember you, XeonTeam. It's been awhile.
Aug 18th, 2005, 01:36 PM
#9
Re: write to text file
Originally Posted by
Jacob Roman
... And Rhinobull, it goes like this. In bold is where I corrected you: ...
Oh, yes of course - result of a freehand typing. Thanks.
Aug 19th, 2005, 08:49 AM
#10
Thread Starter
New Member
Re: write to text file
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..
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width