This is a simple function which will read the file line by line and search each individual line until the target string is found, then return the line number it was found in. It will return zero if the string was not found.
This is a simple function whipped up to demonstrate the basic technique, it has not been debugged or tested at all, and is certainly not the best solution possible. It also lacks any form of error trapping/handling.
You should not use this code in any program intended for production without rewriting it.
public function FindStringInFile(byval strTarget as string) as long
Dim iFile as integer 'file number
Dim iLineNum as long 'counter for line number
Dim strTmp as string 'variable length string to hold string from file
Dim bFound as boolean 'flag to indicate it was found
'First, open the file for input:
iFile = freefile 'get the next free file number
open "filename.txt" for input as #iFile 'open the file in input mode
do until eof(ifile) 'continue reading lines until the end of the file
line input #ifile, strTmp 'read a line into the string variable iLineNum = iLineNum + 1 'increment the line number counter
if instr$(strTarget, strTmp) <> 0 then 'set the flag and exit the loop
bFound = true
exit do
end if
loop
'check the flag
if bFound then
'found, return the line number
FindStringInFile = iLineNum
else
'not found, return zero
FindStringInFile = 0
end if
end function
what is string
uitihyiuiphoiphuihyi
Try using Microsoft internet controlin vb. It is in the components list. Its is very easy to use.
In Visual Basic (VB), you can declare a text variable using the Dim statement followed by the variable name and the As String type. For example: Dim myText As String. You can then assign a value to it, like myText = "Hello, World!". This allows you to store and manipulate string data within your program.
give print then select print to file give the file name that file may prn file by
gov
The Search Key
what is string
Str converts a number to a string.
uitihyiuiphoiphuihyi
vb called visual basic where as c the third letter of english alphabet so the basic advantage is the spelling of vb is very large as compared to c although both are bekar language but still attendence demands completion of file n completion of file demands a good friend who helps in writing a file and for helping that friend we have to search such a "goody goody" questions like this so it is the major disadvantage of vb practical over c practical.
Grep
.vb
Try using Microsoft internet controlin vb. It is in the components list. Its is very easy to use.
In Visual Basic (VB), you can declare a text variable using the Dim statement followed by the variable name and the As String type. For example: Dim myText As String. You can then assign a value to it, like myText = "Hello, World!". This allows you to store and manipulate string data within your program.
give print then select print to file give the file name that file may prn file by
You will need a PDF server running somewhere that can be accessed by your VB code. It will need to be called from the code through the server and get the PDF file in return. I did that with Tweak PDF Converter, an pdf editor for converting pdf file to word form.