VB Program - To Create a Notepad(.txt) File and Save the data
Steps:
1.For Creating a text file in a Vb program we use File System Object.
2.CreateObject ("scripting.filesystemobject") - This is used to create the object of the file.
3.After creating the file object we open the file using opentextfile(location) function.
4.Once the file is opened then writeline is used to write text in the file that has been created above.
5.After writing in to the file ,the file object has to be closed using Close.
Here is a demo to create and then write something in a text file :
The below code will create the Text file(Ia2Tech.txt) and then write the data("Its all about Technology") in the file which will be saved at "D:\Ia2Tech.txt" and then will close it.
Program :
Sub Notepad()
Set objFS = CreateObject("scripting.filesystemobject")
Set txtFile= objFS.opentextfile("D:\Ia2Tech.txt", 8, True)
txtFile.writeline "Its all about Technology"
txtFile.Close
Set txtFile= objFS.opentextfile("D:\Ia2Tech.txt", 8, True)
txtFile.writeline "Its all about Technology"
txtFile.Close
End Sub
Note : If the File is already there at a specified location then the data will be appended to the data already present in the file.