Is there a way to make a Visual Basic file that if you click a button, it will add some text to a text document?
Is there a way to make a visual basic file that adds to a Text Document?
Yes you can use VB to write to a text file.
You do need to consider if the file is New or existing and if it exists do you want to overwrite or append (add) data.
The following will create a new file and write the numbers 1 to 100 in two steps. The first creates a new file called mtTest.txt overwrites any existing file and writes the number 1 to 49. The second pard uses the AppendText method and opens the existing file and adds additional lines of text to the end, writting number 50 to 100.
Dim ts As System.IO.StreamWriter
ts = System.IO.File.CreateText("C:\myTest.txt...
ts.WriteLine("New File Ceated")
For x As Integer = 1 To 49
ts.WriteLine(x)
Next
ts.Close()
ts = System.IO.File.AppendText("C:\myTest.txt...
ts.WriteLine("Appending to existing data.")
For x As Integer = 50 To 100
ts.WriteLine(x)
Next
ts.Close()
In your program you should use code to select a file name and directory. Also test to see if the file exists and prompt the user to delete and existing file, append to it or cancel teh write operation. The above code just shows you how to write data to a file.
Reply:Open "Whets.txt" For Append As #1
Print #1, "PC model .. "; a$
Print #1, "CPU .. "; a$
Print #1, Format(wips, "####0.000");
Close #1
Reply:yes
depends how you want it though
message me back your needs
i was just working on a project where you tick a check box and it opens a text box where you type stuff in and you press submit and it lists them one after another
Reply:This article talks about the VB6 use of the FileSystemObject. That should get you going.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment