473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to read the line one by one and read out the data correspond?

Hello, all:
I have a problem like this:
I created a database in txt.like this:
"143483",1234
"143484",1235
"143485",5588
"143486",5876
"143488",8568
"143487",8756
.......
I want to make a program which can search the data and read out the data using VB.
If I input the 143483 into the program, the result will be 1234.
I programmed like this:
Private Sub Command1_Click()
Dim Target As String
Dim Current As String
Open "E:\test1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, Current
If (Current = Target) Then
Label3.Enabled = True
Text2.Enabled = True
Text2.Text = Barcode.Width
Exit Do
ElseIf (Current <> Target) Then
Do Until EOF(1)
Loop
End Sub
But it is not working. Hope someone can help me to slove this problem. thanksssss a lot!
Aug 10 '06 #1
1 1653
BSOB
77
first things first:
you have opened file as 1, you NEED TO CLOSE IT. bad form to leave it hanging.
second thing:
you have an if statment, you have no end if...?
third thing:
you have 2 do's, and only 1 loop...?

Private Sub Command1_Click()
Dim Target As String
Dim Current As String
Dim Result As Long
'input target ("143483")
Open "E:\test1.txt" For Input As #1
Do
Input #1, Current
If (Current = Target) Then
Label3.Enabled = True
Text2.Enabled = True
Text2.Text = Barcode.Width
Input #1, Result
Exit Do
End If
Input #1, Result
Loop Until EOF(1)
Close 1
'output result (1234)
End Sub
Aug 11 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Artemisio | last post by:
I have done a small currency calculator. It works and I'm very glad. But...I'd like to have a line shift if user types a wrong choice. Please, look at the code and output example down here: #...
2
by: les_ander | last post by:
Hi, matlab has a useful function called "textread" which I am trying to reproduce in python. two inputs: filename, format (%s for string, %d for integers, etc and arbitary delimiters) ...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
0
by: HK | last post by:
Hello, I am new to access/sql-developement and have the follwing problem: What I finally want, is to present within a form the results of a query, that are probably read-only PLUS a field...
0
by: sangui | last post by:
Helllo. this is biginner programmer. Would u check the file that I programed on c#(winform)? I tryed to make the program reading the binary file by C# programming but I failed. If u have...
0
by: sangui | last post by:
Hello. this is beginner programmer. If u have more time, would you check this code.? please give me the answer how to slove this problem...? ÷ºÎ ÆÄÀÏ ==> wtmpx.dat ·Î±× ÆÄÀÏ ...
35
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
8
by: andrew.jefferies | last post by:
Hi, I'm trying to write a simple log parsing program. I noticed that it isn't reading my log file to the end. My log is around 200,000 lines but it is stopping at line 26,428. I checked that...
6
by: arnuld | last post by:
This works fine, I welcome any views/advices/coding-practices :) /* C++ Primer - 4/e * * Exercise 8.9 * STATEMENT: * write a program to store each line from a file into a *...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.