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

search about statement in text file

36
hi for all

i want to search about specified statement in text file via command button

if i click button and the program find this statement it show message box

for example :

the name of file is ssdd.txt

and the statement that write in this file is welcome to vb .

i want if the program find this statement it show message box

how ican do that .

thanks for all
Feb 19 '07 #1
17 1985
dorinbogdan
839 Expert 512MB
Try this sample in a function (I dont have VB installed to check the syntax):
Expand|Select|Wrap|Line Numbers
  1. ...
  2. dim f as integer
  3. dim strLine as string
  4. f = freefile
  5.  
  6.     open "c:\ssdd.txt" for output as #f
  7.  
  8.     while not EOF(f)
  9.          Line Input #1, strLine 
  10.         if instr(1, strLine, "welcome to vb") <> 0 then
  11.              msgbox strLine
  12.         endif
  13.     wend
  14.     close #f
  15.  
  16. ....
  17.  
Feb 19 '07 #2
Killer42
8,435 Expert 8TB
dorinbogdan, the only problem I see is that you opened for Output - should have been Input.

Let's hope the file wasn't anything important. :)
Feb 19 '07 #3
dorinbogdan
839 Expert 512MB
You're right. Thanks for correction.
Feb 20 '07 #4
mse07
36
thanks for you but the problem is :

my file is auto create where i execute batch file it is created

and your codes explain how i create file and how to search in this file

and my problem is how to search in that auto create file .

thank you .
Feb 20 '07 #5
dorinbogdan
839 Expert 512MB
Hmm, The code doesn't create the file, it just opens an existing file, whose name must be known.
You just must replace "c:\ssdd.txt" with the correct path\filename in:
open "c:\ssdd.txt" for input as #f

Let me know if not enough.
Feb 20 '07 #6
mse07
36
but my path file is not .txt it is .log

thank you
Feb 20 '07 #7
hariharanmca
1,977 1GB
but my path file is not .txt it is .log

thank you

.txt,.log,.ini,.bat will open in .txt format
Feb 20 '07 #8
mse07
36
.txt,.log,.ini,.bat will open in .txt format
that is right i try and do that

but how to search about statement in line 13 for example in text file .
thank you .
Feb 20 '07 #9
hariharanmca
1,977 1GB
that is right i try and do that

but how to search about statement in line 13 for example in text file .
thank you .

use while and a increment flag if the flag is 13 then use that statement
Feb 20 '07 #10
mse07
36
use while and a increment flag if the flag is 13 then use that statement
i am sorry

can you explain that by code

thank you .
Feb 20 '07 #11
dorinbogdan
839 Expert 512MB
Expand|Select|Wrap|Line Numbers
  1.  
  2. ............
  3. Dim lngLine as long
  4.     lngLine = 0
  5.     while not EOF(f)
  6.         lngLine = lngLine + 1
  7.          Line Input #1, strLine 
  8.         if lngLine = 13 Then 
  9.             If instr(1, strLine, "about") <> 0 then
  10.                  msgbox strLine
  11.              end if
  12.         end if
  13.     wend
  14. ............
  15.  
Feb 20 '07 #12
hariharanmca
1,977 1GB
i am sorry

can you explain that by code

thank you .
Expand|Select|Wrap|Line Numbers
  1. Private Sub readFile()
  2. Dim f As Integer
  3. Dim LineFlag As Long
  4. Dim strLine As String
  5. f = FreeFile
  6.  
  7.     Open "c:\ssdd.txt" For Input As #f
  8. LineFlag = 0
  9.     While Not EOF(f)
  10.         LineFlag = LineFlag + 1
  11.         Line Input #1, strLine
  12.         If LineFlag = 5 Then
  13.             If InStr(1, strLine, "welcome to vb") <> 0 Then
  14.                 MsgBox strLine
  15.             Else
  16.                 Exit Sub
  17.             End If
  18.         End If
  19.     Wend
  20.     Close #f
  21.  
  22.  
  23. End Sub
Feb 20 '07 #13
mse07
36
the program give me error

run time error (input past end of file )

why?
Feb 20 '07 #14
hariharanmca
1,977 1GB
the program give me error

run time error (input past end of file )

why?
in which line you are getting this error
Feb 20 '07 #15
mse07
36
Line Input #1, strLine
Feb 20 '07 #16
dorinbogdan
839 Expert 512MB
See also this article
Feb 20 '07 #17
hariharanmca
1,977 1GB
See also this article

yes this will solve the problem
Feb 20 '07 #18

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

Similar topics

83
by: D. Dante Lorenso | last post by:
Trying to use the 'search' in the docs section of PostgreSQL.org is extremely SLOW. Considering this is a website for a database and databases are supposed to be good for indexing content, I'd...
2
by: misschristalee | last post by:
I'm having a brain blockage day.... Scenario: Search Form with 6 text boxes Query has same six fields Each has this IIF: IIf(IsNull(!!),"",!!) with each dictating the correct text box of...
2
by: richardkreidl | last post by:
I want to be able to delete and search for elements in a XML file, I'm using the code below for adding elements which works great: Public Sub cmdAddElement_Click(ByVal sender As System.Object,...
0
by: Chung Leong | last post by:
Here's a short tutorial on how to the OLE-DB extension to access Windows Indexing Service. Impress your office-mates with a powerful full-text search feature on your intranet. It's easier than you...
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...
5
by: isabelle | last post by:
hi, every body.. I have two program I couldn’t solve them So, can any body help me. please!! 1-Write a program that accepts a character and count number of occurrences in a file. The file...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
1
by: 848lu | last post by:
hi, im trying to do a search on my Array, where a users searches on a HTML screen and then the PHP searches the array for the data under the roice entred by user.....text file data is under the php...
1
by: wbrands2 | last post by:
I have a basic web form that inserts information into a ms sql database and I am trying to create a search page for it. I am running into the problem that after I insert the information into the web...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.