hi i have a huge txt file
Acct= 1452 Name= Mahesh
Book=124856
now i have a huge txt file which has this data and i want to find a particuler Acct: and it should give me the Name and Book
any ideas how to fo that in vb
plz help if can
sumesh
Private Sub Command1_Click()
Dim txtvar As String
Dim file As Integer
Dim b As String
file = FreeFile
Open "C:\a.txt" For Input As #file
Do Until EOF(file)
Line Input #file, Ln
If InStr(Ln, Text1.Text) > 0 Then
MsgBox "String Found"
Text2.Text = Text1.Text
Else
MsgBox "String Not Found"
Text2.Text = ""
End If
Loop
Close #file
End Sub
hi got the code but now if it finds the account no then it should show me the Name and book name in the text box and exit the program
if you gave any idea about it
the txt files contains data like the following
Acct= 1452 Name= Mahesh
Book=124856
This code search a text on .txt file depends on the keyword you entered. I suggest, if your reading a huge file, why dont use database instead of .txt file. I also suggest that you read the .txt file horizontally depends on the format that is why stickleprojects is asking for a sample text file to see the format.
Private Sub Command1_Click()
Dim txtvar As String
Dim file As Integer
Dim b As String
file = FreeFile
Open "C:\a.txt" For Input As #file
Do Until EOF(file)
Line Input #file, Ln
If InStr(Ln, Text1.Text) > 0 Then
MsgBox "String Found"
Text2.Text = Text1.Text
Else
MsgBox "String Not Found"
Text2.Text = ""
End If
Loop
Close #file
End Sub
hi ya you had the code but the nest step i need to get the book and the name of the person
if that possible
12-10-2005 at 04:57 PM
|
TJ_01 Level: VB Lord Registered: 24-08-2005 Posts: 320
Re: Find in txt file to txt1.text
Can you give us a sample format of your text file containing this information and see what i can do? I find your question very interesting and i want to try.