borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (timer?)Next Topic (run code when closing document?) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Search a keyword in txt and pull the data
Poster Message
sumesh11
Level: Protégé

Registered: 06-10-2005
Posts: 4

icon Search a keyword in txt and pull the data

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

[Edited by sumesh11 on 06-10-2005 at 08:28 PM GMT]

06-10-2005 at 08:28 PM
View Profile Send Email to User Show All Posts | Quote Reply
TJ_01
Level: VB Lord


Registered: 24-08-2005
Posts: 320
icon Re: Search a keyword in txt and pull the data

Would this code helps?

This code finds a word depend on your input in a text file and if found the pull the data into text2.
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






____________________________
Im JAMES  

07-10-2005 at 01:28 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Search a keyword in txt and pull the data
Previous Topic (timer?)Next Topic (run code when closing document?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder