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

25 pts.
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]

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: 1  Reply

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.
  • TheRealRaven
    Visual Basic 6.0 was the last stable release back in 1998, eighteen years ago. Official Microsoft support ended almost eight years ago (though MS has continued to include compatibility sofar, even in Windows 10).

    You're asking multiple basic questions that seem like you need to study VB 6.0 first. Once you know the language, you might be able to present a technical problem that we can help solve. That's much more likely than finding someone who can take the time.

    It's not easy to teach individuals one hand-typed example at a time, especially in a language version that some haven't seen in their careers so far and more experienced members might not have seen for 10 years or more.
    36,975 pointsBadges:

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.

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


Share this item with your network: