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 17 1985
Try this sample in a function (I dont have VB installed to check the syntax): -
...
-
dim f as integer
-
dim strLine as string
-
f = freefile
-
-
open "c:\ssdd.txt" for output as #f
-
-
while not EOF(f)
-
Line Input #1, strLine
-
if instr(1, strLine, "welcome to vb") <> 0 then
-
msgbox strLine
-
endif
-
wend
-
close #f
-
-
....
-
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. :)
You're right. Thanks for correction.
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 .
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.
but my path file is not .txt it is .log
thank you but my path file is not .txt it is .log
thank you
.txt,.log,.ini,.bat will open in .txt format
.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 .
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
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 .
-
-
............
-
Dim lngLine as long
-
lngLine = 0
-
while not EOF(f)
-
lngLine = lngLine + 1
-
Line Input #1, strLine
-
if lngLine = 13 Then
-
If instr(1, strLine, "about") <> 0 then
-
msgbox strLine
-
end if
-
end if
-
wend
-
............
-
i am sorry
can you explain that by code
thank you .
- Private Sub readFile()
-
Dim f As Integer
-
Dim LineFlag As Long
-
Dim strLine As String
-
f = FreeFile
-
-
Open "c:\ssdd.txt" For Input As #f
-
LineFlag = 0
-
While Not EOF(f)
-
LineFlag = LineFlag + 1
-
Line Input #1, strLine
-
If LineFlag = 5 Then
-
If InStr(1, strLine, "welcome to vb") <> 0 Then
-
MsgBox strLine
-
Else
-
Exit Sub
-
End If
-
End If
-
Wend
-
Close #f
-
-
-
End Sub
the program give me error
run time error (input past end of file )
why?
the program give me error
run time error (input past end of file )
why?
in which line you are getting this error
See also this article
yes this will solve the problem
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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,...
|
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...
| |