Save Data to Text File in VB6
Submitted by donbermoy on Wednesday, March 26, 2014 - 04:01.
A text file is considered a plaintext file and Notepad is only capable of creating and editing plaintext files and saves any text file with a .txt file extension. This means no special formatting or different types of fonts can be used.
The easiest way to create a text file in Windows is to open up the Notepad software program on your computer. This is a standard program in Microsoft Windows, included with the operating system when installed.
Now in this tutorial, we will create a program that can write and save data to text file.
Let's start this tutorial!
1.Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open.
2. Next, add only one Button named Command1 and labeled it as "Save". Insert also a textbox named Text1 and make it empty. This will used as a data to be saved in a text file. You must design your interface like this:
3. Now put this code for your code module. This code is for Command1_Click:
Open Statement here enables input/output (I/O) to a file which means it will create a text file named Text1.txt. The mode here is the Append means to write a file as #1. Then it will write the inputted text in your textbox and will saved at text1.txt and will prompt the user that the text has been saved.
- Private Sub Command1_Click()
- Open "Text1.txt" For Append As #1
- Write #1, Text1.Text
- MsgBox "Text Saved!"
- End Sub
Output:
Download the source code and try it! :) For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISwareAdd new comment
- 4692 views