473,322 Members | 1,188 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,322 software developers and data experts.

how to search word in text file using access vba

guys

i have text file and i have to serch word in that file using access vba code

i am not understanding how to write code for searching particular word.....

i have tried following code BUT THERE IS PROBLEM

Expand|Select|Wrap|Line Numbers
  1. Dim objStreamReader As StreamReader
  2.     Dim strLine As String
  3.  
  4.     'Pass the file path and the file name to the StreamReader constructor.
  5.     objStreamReader = New StreamReader("C:\Boot.ini")
  6.  
  7.     'Read the first line of text.
  8.     strLine = objStreamReader.ReadLine
  9.  
  10.     'Continue to read until you reach the end of the file.
  11.     Do While Not strLine Is Nothing
  12.  
  13.       'Write the line to the Console window.
  14.       Console.WriteLine(strLine)
Aug 28 '12 #1
2 2763
zmbd
5,501 Expert Mod 4TB
Well, that is oneway...

Some will prefer the filesystem object

I would more than likely use the OPEN "filepathasstr" FOR input AS #1 followed by the INPUT #1, somevarabable and then parse the line.

You should google "VBA Open" and "VBA input" for detailed information and also take a look at: http://www.applecore99.com/gen/gen029.asp

-z
Aug 28 '12 #2
NeoPa
32,556 Expert Mod 16PB
Prasad:
BUT THERE IS PROBLEM
That tells us nothing about what the problem is. You also tell us nothing about the format of the data in your file. It's a wonder you get any replies at all with such a poorly expressed question.

I suggest you think about these issues. Z has already suggested a solution that doesn't require any extra libraries be referenced, but there are other approaches available with the Open command and the FileSystem object is quite popular too, so will appeal to some.

It's hard to be more help at this time though, without a properly expressed question.
Aug 28 '12 #3

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

Similar topics

2
by: Simon Verona | last post by:
Not sure if this is the best group... it may be better off in one of the ADO groups, but I'm sure somebody here knows the answer: I'm trying to load up a text file using ADO.net, as follows: ...
2
by: Praveen_db2 | last post by:
Hi all Db2 8.1.3 windows Is there any way to write data into a text file using a stored procedure? The way we return a cursor output to the calling application, can we return data in a text...
3
by: mse07 | last post by:
hi all i search about statement in text file by this code : LineFlag = LineFlag + 1 Line Input #1, strLine If LineFlag = 15 Then If InStr(1, strLine, " Transfer completed...
1
by: rajap | last post by:
How to write all the links of the google search result page into a text file using C#.
4
by: varsha desai | last post by:
Hello there, I want to change some data(which is in one line only) of text file using VB 6.0. Which is the best method for it? Another question is I want to delete last two, three lines...
1
by: Phil | last post by:
I want to add a button to a form to import a text delimited file. The File is delimited by "^" and so I have created a specification file by manually impoting the text file, using the advanced...
2
by: sajidali | last post by:
i am trying to append a text file using c#. when i executes my application i writes to the text file using more then one functions. i want to append file only during execution of programe. next time...
1
by: ahmed222too | last post by:
i use vb6 i want to make a backword search in text file i mean (by backword search) to begin the search from the last for example (i will go to school to learn more....) i want to find the last...
7
by: vgnadeau | last post by:
Hi. I would like to know how to count the number of occurances of a word in a text file. I am using Microsoft Access VBA. Any ideas?
4
by: LizAmmo | last post by:
For a school project i am attempting to create a register and login section of a program. i have managed to create the register by writing user names and passwords to a text document, as we cannot...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.