Searching A Text File.
how do you search a text file for a certain word and then delete it from that text file in vb 5?------------------Mooose
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Searching For A Directory Vs Searching A Text File For The Same Thing!
After working on a piece of code for a while, and actually getting it to work, I was asked to do it a different way.
Originally, I had a login box set up to search for a user's username and password that was stored in a text file. The problem with this was that I didn't know how to get it to search ALL of the entries, not just a set 1 to 10 like I was using in my code. To see the full program code, click here.
Now my group members want me to do it so that it searches for the directory instead of the text file for the same information. The directory name is the username, and in the directory, they'd like (theoretically speaking) to have the user's username and pass stored in a pwd file or a txt file.
I'm trying to argue that searching a text file's easier (partly because I believe it is, and also because I've already done it), but they're arguing that searching the directory's easier because then, the program could just store the directory in a global module, so when it comes to other aspects of the program itself, it'd be easier to do.
I'm willing to give the 'searching for the directory' route a try, but I can't seem to find anything that pertains to this, WITHOUT using api (I've searched the forum, and all I found was recursive search for stuff thats already in a directory, or stuff that has to do with api).
Any help would be greatly appreciated.
Searching Text File For A Group Of Text.
Does anyone know the most efficient way to search a text file for a group of lines? For example, if the file was:
d = xxxxxx
a = xxxxxx
b = xxxxxx
d = xxxxxx
c = xxxxxx
e = xxxxxx
b = xxxxxx
where xxxxxx is any set of numbers.
and you wanted to search for the block of strings:
b = xxxxxx
d = xxxxxx
c = xxxxxx
Is there a quick and efficient way beside reading each line, matching against the first line, checking if the line following it is the second line, etc?
TIA
Bishop
Searching Text File
Greetings!
I am struggling to search a group of files for a specific string. I have used the Application.FileSearch in Excel VBA but I do not know of the alternative file search methods available in VB.
Your suggestions guys?
Searching Text File
is there a way to open a file, search through each line for the first 5 char to find a certain string, and if it's there then get the data to the right of it and edit it then save it back to the same location?!?!
i have the searching part, but i have no idea how to get the row, or column(if thats possible) or anything
thanks
Searching A Text File
I am writing a small program to screen pop our ACT! Database from our CTI program, I have tried using a method that searches the database using the SDK tools but it is too slow.
Another utility creates a CSV from the database which is used for another purpose but the CSV contains the phone numbers and the unique ID of each record and with the Unique ID i can tap straight into the database very quickly.
The CSV File containing about 8000 lines each with 8 fields, I would like to search in the file for the appearance of the phone number and then use the contents of field 8(Unique ID) further in the program. The phone number could appear in multiple lines and i would like to have it display a choice between these records.
I Am a newbie coder so any help with methods of searching this CSV would be greatly appreciated. Search speed is the key feature i need.
Please Help
SkreeM
Searching A Text File.
I have a text file that has the following: name, ID, average, Grade. What i want to do is have the user input an id and i want it to search the file for the id and if it's found i want it to output all the information related to that id number. i have the code to open so all i need to do is search it. the id's are between 1000 and 2000 would i just do a loop that runs through those numbers and if it finds a match have it out put or what? i'm clueless here.
Searching Through A Text File
I would like to be able to extract certain data from a text file for my program and have no idea how to do it. I've searched through all my VB books but I'm still confused.
Here's the scenario.
The external txt file contains comma delimited data that would look something like this:
Amount,11000,Amount,5000,Amount,1000,Amount,11000
The real thing contains more data, but the above is more specific to my needs.
I would like to set it up where the user would click a button, the program would go through this file (located in the root of the c: drive) and add up all of those amounts. Then return the total to a txt box.
I know this is a bit much, but any ideas would help.
Thanks!
Searching Through A Text File
Hey, i want to create a program that searchs through numbers in a text file, its for a hockey manager game (EHM if you've heard of it). Basically i want the program to display the Players name as well as their Potential number and Consistency number. Both numbers are two digits and are among several thousand numbers in the file. This is to make it easier to look at whose good in the draft so there will need to be some sort of code that only displays players born in a certain span of years such as 1986 - 1988.
If anyone could help me it would be much appreciated.
Thanks in advance
Searching For Text In A File
Hi All,
Using fileSystemObject or any other tool, how can I programmatically search for a text/word in a file.
Example: If I've 100 files in a folder and I want to search for a word "ERROR" exist in those files. Instead of using the windows "search files and folders", I want to write a program that can do it.
Cheers
Searching Text In A File
Ok, I know I posted about this before, and all were good suggestions, but none helped with my problem.
I have this bit of code -
10.1.6.248, EPCUSD_#401username, -, Y, 12/16/01, 13:50:29, 1, -, -, www.aol.com, -, 80, 90, -, 820, http, -, -, http://www.aol.com/popups/script/non_popup_memEd.js, -, Inet, 10054, 8389635
What I want to do is if I enter the username I want the program to show me all the web pages the person has been to in a list box.
I have the part where it finds the username already, but I cant get the part where it pulls the http://ect...
Any Ideas
Searching Text File
Hi,
I have a text file that is the result of a SQL query. How would I run a search on it according to something that a user puts in 2 two boxes (First Name and Last Name)? I then want to show the results in either a seperate form or a message box...
Thank you
Searching For Value In A Text File
I am creating a program to save data to a sequential access file and I am able to write data to the file using multiple textboxes. When I save the data to the file, one line of
text constitutes one record.
How can I open that file and perform a search for a value, then when it is found, populate the corresponding textboxes?
Any help is much appreciated!
Searching A Text File
To whom may help..
I am trying to write a program that will open one file #1, for input, read one line at a time. Open a second file #2, search thru text of file #2 for the information from file #1. I would also like to know how to set a search start and a search end and collect all information in between.
Thanx
Searching Through Text File?
How do I seacrh a string through a text file and when the text is found, separate small strings separated by semicolon( and display them in different textboxex.
Any help will be appreciated.
Thanks in advance.
Kinjal
Searching A Text File.
how do you search a text file for a certain word and then delete it from that text file in vb 5?
------------------
Mooose
Searching A Text File...
I created a database to store records and had no problem returning query results. However, I was told that we can't use Access and that the records need to be stored in a semi-colon delimited text file.
I have no clue whatsoever how to write a search. This file holds over 260,000 records so speed is possibly going to be a problem.
The file format is (semi-colon used because of name Format with comma):
ID; Lastname, FirstName; Sex; Date of Birth; Mother's Name
Originally with the database I selected a field to search and ran the related query with the criteria pulled from a text box. Now I'm thinking that I just need a text box and run the search for matches from that single text box.
A piece of code to get me started would be lovely. Or... if you have links to any tutorials that would be great to.
Thanks,
Phil
Searching A Text File?
Hi.
I have a text file which in which the lines are numbered this way:
[flightsim.0]
[flightsim.1]
-
-
[Flightsim.43]
and so....
I want to append some text to the textfile and wants to find out what the
highest number is, i.e. 43 and then add 1 to this number for the text to be
appended.
How do i do that?
Kind regards
Frank
Searching The Text Of A .pdf File
Hi, I am creating a project that involves displaying .pdf files. I would like to be able to have the user type in a search parameter/keyword and then search through a directory of .pdf files to see if their keyword is contained in any of the documents. Thank you in advance for any light you could shed on this.
Searching Through A Text File
I am doing my a level visual basic project, and have a problem. My program is for a shoe shop, with a stock control system and a till system. I add the details of a shoe (barcode, name, price) into a text file from my stock control system, and in my till system i want to input a certain barcode, where it will search for this barcode in the saved text file until it finds the corresponding record, and as a result brings the corresponding name and price of the shoe onto the screen. How do i do this? Do i need to separate each individual variable (barcode, name, price) by a comma? because when i open the text file it is stored like so: "Slipper 49.99 34583248 Ross † 12365478" (These are two records, the "slipper" and "ross" are the names of the shoe, the 8 digit nos are the barcodes, and the other symbols are the price and quantity (?)) btw, i also need it to take one off the quantity each time i input the barcode (this is when a sale is made). Help would be much appreciated. Thanks, ross
Searching Through A Text File
Ok, I am making an AIM program and the only way I know how to check for their username/pw is that when they connect it checks a text file on my computer (the server) for there name, so in englis hthis is what i want it to do:
search "c:/names.txt" , "username"
if it finds it then it sends oktoconnect, basically search a text file for a string and tell me whether or not it found it, sorry for that unexplanatory question but im in a hurry (= thanks in advance.
Searching A Text File
How can I search through a text file to find words or phrases. I need to search a log file for errors.
Thanks for any help you can provide.
Dave
Searching A Text File.
Hello all,
am trying to have a list of about 60,000 words(.txt file) searched and the results/partial match displayed in a text box. It will be used as a spelling reference for specialty words. I know that a list or combo box would do what I am looking for but populating it with that many entries would be a nightmare. Any ideas as to how I could accomplish this? I have tried to populate a table with the text file in a VCE form but it crashes the PPC and requires a hard reset. Any help/direction would be appreciated.
Rod
Searching A Text File
Does anyone know how to programmatically open an existing text file. Then search through a comma delimited file(like the portion below) for a string, '475'.
16,301,13981439,Z,IA0010,012040/
16,301,4756071,Z,IA00045,000000/
16,475,72363175,Z,IA00025,012040/
16,475,42736600,Z,IA00025,012050/
Thank you
No L c
VB Developer
Searching Text In A File
Hi,
I want to search a text in all the files in a directry.Please tell me if there is any easy way to do that.
Thanks,
-arun
Searching A Text File
need help with source code for an application which will accept a string from a text box and then search a text file for a matching string and then display its contents. if there is no matching string then the next compatable result should be displayed. can anyone help ?
Reading/Searching Text File
I tried searching the boards for the answer to this, but all i could find is bits and pieces. All I need is some simple code on how to read from a text file, and how to search through a text file, then take the items its found, and place them into variables.
For example
I have a text file called text.txt. The contents of the text file are as follows:
One
Two Three
Four Five Six
Basically what would be the code to pick out the string "Four Five" from the text file and place it into a variable. It would need to search through the entire file, to see if there are several instances of "Four Five".
Im sure this has been answered several times, but I couldnt find it
Searching Record In Text File
hi guys,
everything in this bit of code is doing fine...
but my combobox gets all the record in textfile, all i want is only the first column of the record...
give me some hints...
please help me..........
Private Sub cmd_Click(Index As Integer)
Dim f As Integer
Dim findstr As String
f = FreeFile
Select Case Index
Case 0 '-----CmdAdd---------
Open "c:sample.txt" For Append As #f
Write #f, Text1(0).Text; Text1(1).Text; Text1(2).Text
Close #f
'Call clear
'-----------problem here------------
Case 1 '------CmdSearch------
Open "c:sample.txt" For Input As #f
Do While Not EOF(1)
Input #f, findstr
Combo1.AddItem findstr
Loop
Close #f
'Call clear
End Select
End Sub
tnx
Searching For String In Text File
I am stuck again. I've searched the forum the all that I can and I am still stuck.
I have a program setup so that all the strings in lstConsole writes to a text file. I was wondering if you can tell me if it is possible to search that text file for a specific string, and if that string is there do this
not code
If text.txt has string "i shot the sheriff" then
lstconsole = "but i did not shoot the deputy"
I will be grateful for any help you can give me, and if its not to much trouble please explain it to me like I'm a 5yo.
Searching A Text File For A String
Hi,
What is the quickest way to find out if a text file contains a specified string?
I have a program that adds a string into HTML files. I do not want to add the string if it already exists in the file. I am processing upto 50 files at a go. (I am reading the file line by line until I find the right spot for the string.) Is it possible to read in the whole file in one go into one string and then do an instr command?...or something.
Thanks for any advice.
Searching And Modifying A Text File
OK, this is a pretty basic thing, and if search was working, I would probably find the answer in there. So bear with me, I know this has probably been covered a million times.
I'm writing a program that reads a text file, which is basically a bunch of records, displays them, allows the user to edit them, and saves the changes back in the file. (Obviously, this thing would be accomplished so much better with a database, especially since we're looking at uber files on the order of 1+ MB. But the file is already in text format so that's what I have to work with.)
So, my question is, I haven't done file handling in quite a while, and I'm not sure what the best way to go is. I was thinking about using the FileSystemObject to find and manipulate the file, then I thought about using the Word ojects, since it has find capabilities built in. I'm not that familiar with either of these objects, so I don't really know if one is better than the other, or if there's a better solution. If anyone can give me some tips, or point me to some info, I'd appreciate it.
Thanks.
Searching A Text File For For A Match
I have a form to disarm a security system I am building. On cmdDisarm_Click I want to check txtPassword for a match of a password in a .dat file. As I am new to VB I would greatly accept your help...
Roger
Help With Searching A Text File Using Wildcards
Firstly, im a newbie at coding.
secondly can a search be done on an opened text file using wildcards and then printing the result of the search to a text box?
e.g. i want to search for '*' (star being the wildcard and showing only whats between the appostrophies) then printing the result to a text box. i have used:
open "c:file1.text" for input as #1
but dont know how to actually perform the search.
hope this is clear and hope i get a quick reply.
thank you for your time in advance.
Searching And Writing To A Text File
I am using Access to manage a multi-format, multi-language web site. I need to write information from two different tables to a single text file. Because of the work I have already done, and to avoid creating any new tables, the easiest thing to do would be to run my first macro, which would write to the text file and leave a marker (which could be anything that would be easy to find, I figured a comment which would be invisible to the browser). I then want to create a second macro which would open the text file, locate the marker, and replace it with data from the second table.
Is it possible to do this?
Thanks!
Reading And Searching A Text File
Here is a snipet of a log file I need to parse for license usage:
13:35:00 IN: "application" user1@computer1
13:35:22 IN: "application" user2@computer2
13:38:37 OUT: "application" user1@computer1
13:35:00 OUT: "application" user2@computer2
This log file has when a computer check out a license and when it return it. So for each computer I would like to calcute how long it used the license.
I would greatly appriciate any help you can provide to get me started. I know how to read a line and parse the data I need from it, but this goes way beyond that.
Thanks
dmathieu
*** Searching Any Word From Text File ? ? ? ***
heloo....
i am using vb and asp with sql server 2000 for devloping my new project....
i am new to asp ......
my project is almost over
now i want little help....
i want to search a specific word enter by user in text box(in vb form or asp form) from text file.
is there is any way to find any word from text file.
thanks in advance.........
Searching In A Large Text File
Hello, I'd like to search for movie names in a large text file and return the matches. I know how to do it with predefined words, but what I'd like to do now is more complicated.
This is the code I normally use with predefined words.
Code:
Private Sub Command1_Click()
Dim sLines As String
Open "C:movielist.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, sLines
If InStr(1, sLines, "matrix") And InStr(1, sLines, "revolutions") Then
Text1.Text = Text1.Text & sLines & vbCrLf
End If
DoEvents
Loop
Close #1
End Sub
Now I have this in a textbox:
Code:
!search matrix revolutions final end
If "!search" is in the textbox, then the other words (excluding "!search") need to be used as search strings, but only if they are at least 4 characters. In this case "matrix", "revolutions" and "final".
I know I can find out if "!search" is in the textbox with the Left function and that I have to put the words in an array, but how do I only add the words with at least 4 characters to the array and how do I use the array to search in the text file?
Code:
Private Sub Command2_Click()
Dim strArray() As String
If Left(Text2.Text, 8) = "!search " Then
strArray = Split(Text2.Text, " ")
End If
End Sub
Searching Text In Hindi File.
Hello friends ,
I am doing M.Phil (Hindi) . My project is to develop google search in hindi . I have good knowledge in computers and c and c++ languages and a little knowledge in VB.
My question is
How can I search a hindi word in hindi text file ? Suppose there is a word LADAKA in hindi if in the file it is in the form of LADAKE then how can I can recongnise because in programming we can not type hindi font to compare . I know upto how Can we find a word but if it is exactly in that form then only it is possible.
So ,please give me programe in C or Vb.
FILE HANDLING & SEARCHING TEXT
I just want to know how to search a particular text from a group of files in a directory and then change the
search text to another text. Could you send me a detailed coding regarding this.
Thanks in Advance.
Krish.
Searching For A Known File Name And Changing Text
We are getting ready to switch from one software to another, the new software will follow the existing directory structure but I need to change the format of text within a file in each directory. Example within each directory there is a file called "flow.txt" right now it has "field 1, field 2, field 3 " the new software has additional fields that can be left blank but has to be formatted like this "field 1,,,field 2,,field 3" is there an easy way to search the server for the filename and change the format within the file? I'm just starting to learn vb and was handed this and told to see what I can figure out. Any help or pointing me in the right direction would be appreciated.
Searching A Text File Using A Dynamic Array
Hi All,
I have been working on this problem for a few days but am no nearer a resolution. Before I go into detail, I would like to preface by saying that I am aware that a database application would work much better than what I am trying to do.
I am trying to create a form that will allow a user to input an area code and 7-digit telephone number. The app will take that telephone number and query a text file (.csv) to determine if a match to that number resides within the file.
I have been able to create a simple code to read the file and return numbers off of the list in sequence. What I need is for my code to read all numbers and only return the one that matches the user input if it exists. I have set up an array that will pick up multiple numbers based on the subscript. However, I need the subscript to be dynamic as records within the text file will be changing all the time. Furthermore, I need the subscript to be able to accomodate a large number of strings as the text file will contain between 600,000 to close to 1,000,000 phone numbers.
I have been researching examples of dynamic arrays on this forum for hours, but I just do not quite understand how they work. Any advice anyone can offer would be greatly appreciated.
Searching File For Specific Text, And Replacing It.
Hello,
I haven't programmed in years, and just want some ideas how to go about doing something. I am also new to this forum. I have a file that looks something like this:
AIX concord 2 5 000AD85D4C00 07/04/06
System Configuration: lcpu=4
08:00:00 %usr %sys %wio %idle
What I want to do is search for the line that contains "System Configuration: lcpu=4" and delete it. I also want to delete the empty line below that line. I started of small by seeing if I can write to a file, and also replacing the text within a file. But for me, this is a bit more complicated. I read a bit about the replace function, but I want to find that line of text, and delete the two lines below it. Any idea?
Thank you.
Searching For Specific Text In A Disk File
Ok, I'm pretty new to Visual Basic, and I'm attempting to write my first program. I've been able to find or figure out most of what I need, but I'm stuck on this part. I'm using a disk file (a notepad document, to be more specific) to store records. I want the program to search for a certian string of text and be able to use that and the lines that follow it to input information into a listbox. I know how to imput the info. I just basically need to know how to search for it.
Searching A Multilined File For Text And Adding It
Hi, I'm some-what new to VB but i'm familiar with the general coding concepts.. but i'm lost in this one. So heres my question.
Say I have a multilined file, of any legnth.. (it varies).. how can I search the file, line by line, and check to see which lines have a ";" in front of them? And if it doesn't have one, then add one?
Example file:
----
Stuff1
;Stuff2
Stuff3
----
I want to read the contents of that file, and then for each line that doesnt have a ";" in front of it, add one.
Thanks for the help
-Angel
P.S. Please include comments in the code that would explain it to me as throrough as possible... if I could chat with one of you on AIM, MSN Messenger, Yahoo messenger, or ICQ that would greatly help me..
Searching A Text File Loaded Into Textbox
Hi all, I am trying to search a textbox that has a txt file loaded into it (using common dialog), and i want to search for a word or 2 to find the part i want. Then I want it highlighted, or even just maybe visible in the textbox. All I can find anywhere is search and replace functions, and I dont want to replace, just find the word(s) i need to see
Any help please
Thanks
Dragnut
Searching And Deleteing String In Text File
i am useing this code to delete a line # in a text file:
Open "C:windowssystempersonnel.txt" For Input As #1
Open "C:windowssystempersonnel1.txt" For Append As #2
Do While Not EOF(1)
Input #1, LineStr
Line = Line + 1
If (Line <> linedel + 1) And (Line <> linedel) Then
Write #2, LineStr
Else
'Ignore the line
End If
Loop
Close #2
Close #1
Kill "c:windowssystempersonnel.txt"
Name "C:windowssystempersonnel1.txt" As "C:windowssystempersonnel.txt"
my question is i have alot of chkboxes in array and is it possible to delete a text line by searching for the words that you want to delete instede of the line number?
Searching For A Range Of Values In A Text File
i have these data files, text files, where each 'column' of data is delineated by a vbTab, and each record a vbCrLf
in each line, in the exact same place (after the third tab and before the fourth) is a number.
what i was hoping to figure out was how to search for that number if it lies inside of a range, as in >=x and <=x
for example
text text text 300 text text
text text text 600 text text
text text text 500 text text
text text text 100 text text
text text text 40 text text
text text text 123 text text
text text text 776 text text
text text text 778 text text
text text text 900 text text
and i want to search for values >=200 and <= 500
result
text text text 300 text text
Searching A Text File And Returning Result
i have my data stored to text files. now i want to search the text file and have the results print to another text file, or a string. what i want the search to do is look in each line of the text file to see if the text (or a part of it) exists in the line.
the line can hold up to 50000 characters. not sure if that makes any difference.
there is no header in the text file. just lines of text
for example
abc [tab] 123 [tab] hello [tab] dolly
a2c [tab] 123 [tab] jello [tab] dilly
a3c [tab] 133 [tab] hello [tab] dolly
a4c [tab] 1e3 [tab] jello [tab] dally
so i enter my search term "dilly"
the result is
a2c [tab] 123 [tab] jello [tab] dilly
or lets say "dolly"
the result is
abc [tab] 123 [tab] hello [tab] dolly
a3c [tab] 133 [tab] hello [tab] dolly
is this possible?
|