|
-
Aug 21st, 2000, 11:00 AM
#1
Thread Starter
Addicted Member
I'm having trouble saving data to a textfile. I can save the filename but cannot write the data to that file. Can someone help??
Heres an example of the code I have so far:
On Error Resume Next
CommonDialog1.Filter = "All Text Files (*.txt)|*.txt"
CommonDialog1.ShowSave
strOpenFile = CommonDialog1.Filename
Set ts = fso.CreateTextFile(strOpenFile, True)
strData = Text1
ts.Write (strData)
ts.Close
-
Aug 21st, 2000, 11:05 AM
#2
Frenzied Member
Rich text boxs have their own built in save feature
Code:
rtb1.savefile "C:\Myfile.txt" , rtfRTF 'to save
rtb1.loadfile "C:\Myfile.txt" , rtfRTF 'to open
-
Aug 21st, 2000, 11:10 AM
#3
RichTextBoxes use up a lot more resources too. Next example will save data from Text1 into a file called MyFile.
Code:
Open "MyFile.txt" For Output As #1
Print #1, Text1.Text
Close #1
-
Aug 21st, 2000, 11:33 AM
#4
Junior Member
Sub SavetxtFile()
'Assign constants forwriting numeric value
Const ForWriting = 2
'Set fso as object for writing to output file
Set fso = CreateObject("Scripting.FileSystemObject")
'Set SavetxtOutFile = file path
Set SavetxtOutFile = fso.OpenTextFile _
("c:\windows\desktop\savedtxtfile.txt", ForWriting,True)
'Write txt here
SavetxtOutFile.write "Here is the text I have saved."
'Close txt file
Set SavetxtOutFile = Nothing
End Sub
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
|