How to fetch data from notepad in VB6.0 like a backend database

25 pts.
Tags:
Notepad
Visual Basic
Visual Basic 6
I am having a VB6.0 application and in that I have designed a form with text box & command button. Having a notepad separately in a specific drive like (E or F or G) and that notepad is having a data around 2000 row like (1332,7063413205). Now I want to connect notepad from VB as a backend and want to fetch data by giving 4 digit number in one text box and matching 10 digit number in another text box in VB 6.0 by clicking a button in the form. Whether it is possible to get that! Please help me. Thanks for your support.

Software/Hardware used:
Notepad, VB6.0

Answer Wiki

Thanks. We'll let you know when a new response is added.

Either put this in a a open buttons click event or do it when the form loads:
Open “C:\path_to_your_file\file_name.txt” For Input as #1

Put this in your next buttons event:

Dim temp as String
Dim data() As String
Do While Eof(1) = 0
line input #1,temp
data = Split(line, ",")
TextBox1.Text = data[0]
TextBox2.Text = data[1]
Loop

Either put this in a close buttons event or put it in your form close event.
Close #1

You will need to add error handling. If one line of the file doesn’t contain two elements this code will throw an exception. Wrap the assignments of the text boxes in an if statement that check to make sure the data array has the correct number of elements.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following