Searching A Large Text File And Returning A Searched Word?

Jul 12, 2011

My app is a Bible Reader. At load up I can choose Genesis Ch1 and its entirety pops into a rtb. I enter a word to search for like 'God' and hit the SEARCH button. The results I get are initially what I want. I get the verse 1:1 In the beginning God created the heaven and the earth. But then the app replaces the script with other words containing God, but all jumbled up. Here is the code I am using: Private Sub ToolStripButton2Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2Search.Click Dim stSearch As String stSearch = Me.ToolStripButton2Search.Text For Each Line As String In File.ReadAllLines(Path.Combine(Application.StartupPath, "Bible VersionsKJV 1611King James Version of the Holy Bible.txt")) If Line.Contains(Me.ToolStripTextBox1.Text) Then Me.RichTextBoxViewer.Text = (Line) End If Next LineBryn Ryver

View 2 Replies


ADVERTISEMENT

Searching A Text File And Returning Results?

Nov 25, 2011

I have been taking a class in Visual Basic and am currently working on my final project which I am having some trouble with. I am using Visual Basic 2010 express The project is to create an application that will store data in a text file, specifically, Last Name, First Name, Customer Number, Address, City, State, ZIP Code, Telephone Number, Account Balance, and Date of Last Payment. I have gotten everything done except the ability to search the file by Last Name or Customer Number. I have no idea how to go about this? I was thinking of ways to use indexof or Readline to be able to search the data, but I'm not familiar enough with the code to come up with a good solution. Below is a picture of how my form looks..As you can see, I'm currently using 2 separate forms to get the data from the user. Here is the code for Form1 which is the "Customer Accounts" form in the picture.

Imports System.IO
Public Class Form1
Public customerFile As StreamWriter ' Object variable
Public customerFile1 As StreamReader ' Object variable
Public strFile As String

[Code]...

There isn't enough room to post the code for my secondary form, but you get the idea. I would like to be able to enter a search term in the textbox on the bottom right of the form, and either search the data as its displayed in the listbox, or search the actual file? I was thinking that the results would be displayed in a messagebox?

View 3 Replies

Searching For A Word In A Text File Returns The Word And The Sentence Plus A Bunch Of Other Weird Characters?

Nov 8, 2010

I can search for the word Love in an .rtf file and return every occurance of the word into a RichTextBox. It returns the word and the scripture the word is in, but it also isreturning a bunch of weird text like: archan78988yykp etc etc. How do I onlyreturn the scripture with the searchedword, in this case the searched word is love. The code I am using is as follows:

<
If Line.Contains(Me.rtbSearch.Text) Then
'show search form

[code].....

View 1 Replies

VS 2010 Searching Large Piles Of Text For Keywords?

Mar 27, 2012

I have a requirement to search large piles of text for keywords

The "keywords" are known in advance - but the number is variable.

The text is large - I've had 50000 byte strings in tests already...

View 22 Replies

Uppercase Only First Letter In Searched Word?

Nov 13, 2010

I finally can create a lowercase word like "wife" to uppercase. However, there is now an unseen problem. Instead of only Uppercasing the First Letter of the word like "Wife", it is UPPERCASING the entire word like "WIFE". How to only Uppercase the FIRST LETTER in the searched word?

View 7 Replies

VB: Searching For Text Within All PDF Files And Returning Results Of PDF Files Where Text Are Found On

Jun 20, 2011

On a image file (PDF), the OCR has recognised the picture and text. However on Visual Basics, how do you search for a text on this image file? The primary goal is to allow a text search (i.e POxxxxx) on all the image files (PDFs). The returns of the search will be the assciated image files where the text (i.e POxxxxx) is found on.

View 1 Replies

WebMethod Not Working When Returning Relatively Large String?

Jul 6, 2010

I am using Virtual Basic with ASP.NET in Visual Studio 2008. I am using Webmethod to communicate from/to the server with the client. Data can be queried and returned in small amount, but when I try get a relatively large amount of data, it's returning me a Server 500 error. My data is 226561 character long, so it's not that large, but it's relatively larger than my other working testing set, which are about 10k character long.

JavaScript:
PageMethods.my_func("context", success);
function success(result, userContext, methodName) {

[code].....

View 2 Replies

VS 2008 Searching A Large String?

Jun 27, 2009

I haven't programmed for some time, so I'm a little rusty Basically I'm storing HTML within a variable, and I need to count the amount of times a specific element appears e.g. <h3 class=r> for now.

I thought of using a for each loop, and passing the string above into the parentheses of the loop (using a variable ofc) however for many reason's, I don't think this has a chance of working (won't bother explaining why, as I assume you can guess). Then thought of using the .Contains method of the string class, but I simply can't think of how to use it with what I'm trying to do.

View 2 Replies

Searching A Database And Returning Results In A VB Form

Mar 30, 2009

I have a problem which I have tried to solve in several ways, and by searching the Internet for various terms, searching through books and Visual Basic instructional videos, but none have yielded the correct results. My goal is as follows:

1. Create a Database listing job names, job numbers, and a link to the file about the job.

2. Create a form with 2 text boxes, a search button, a box to display results, and a preview panel.

The two above steps have been completed. The following is where I get stuck

3. I want to search for either the job name, and/or the job number, have VB search through the database and return the results in the results box.

4. On clicking on one of the results in the result box, the preview panel will show a preview of the file.

Notes:
i) The files being linked top are Microsoft Excel files.

ii) The box I have used for the results currently is a listbox, though I've no idea if this is the correct choice for what I want to do.

iii) The database I created is an *.xml database created in Visual Basic. I am a fair beginner to VB, learning as I go, but I'm stumped as to how to achieve this so any pointers on how to achieve points 3 or 4

View 2 Replies

VS 2008 Add The Word To A Text File And Create A Folder With The Word As Its Name?

Apr 25, 2009

The following code allows words to be added to a listbox. Add the word to a text file and create a folder with the word as its name. The second part undoes the actions.If I try to delete the word immediately after adding it one of two things happen.

1.An error is reported stating the path cannot be found. Although the listbox index value is correct according to the code the error is pointing at that index +1.

2.The code continues to the point of requesting conformation to delete the folder, still pointing at the index value +1. I the action is confirmed the wrong folder is deleted.

However if I stop debugging, then run the code again all works correctly.Is it likely to persist when the application is compiled?

Imports System.IO
Public Class Form1
Dim pathlist As String = "M:Visual Studio 2008ProjectsEnvironment and Conservation GlossaryEnvironment and Conservation GlossaryGlossary List.txt"

[code]....

View 6 Replies

Javascript - WebMethod Not Working When Returning Relatively Large String

Dec 9, 2011

I am using Virtual Basic with ASP.NET in Visual Studio 2008. I am using Webmethod to communicate from/to the server with the client. Data can be queried and returned in small amount, but when I try get a relatively large amount of data, it's returning me a Server 500 error. My data is 226561 character long, so it's not that large, but it's relatively larger than my other working testing set, which are about 10k character long.

JavaScript:
PageMethods.my_func("context", success);
function success(result, userContext, methodName) {

[code]....

Is there anything I can change to increase WebMethod returned string length limit? Is there even a length limit or is it some other problem I could not see?

View 1 Replies

Searching Large Binary Files And Data Carving

Mar 12, 2011

I am trying to develop an application that will let me do the following

1) Be able to search to large binary files for a specific byte array (header) and to continue searching for another byte array (footer). Then i want it to copy the section of the binary file between these 2 locations to a specified file. Then the program is to continue searching for any other header/footers An example would be search a large file and carving out the jpgs it finds etc. This routine would have to be able to handle raw images of 20gb or more if needed.

View 10 Replies

Writing A Program/searching A Text File For Text

Apr 21, 2011

Write a program that requests a color as input in a text box and then determines whether or not the color is in the text file. The program should use the Boolean-valued Function procedure IsCrayola that returns the value True if the color in the text box is a Crayola color.

*I am to use a file named Colors.txt

View 1 Replies

Display Records Searched In Text Boxes To A Datagrid?

Jun 6, 2011

I am creating an application which will allow users to search parents names and display their childen respectively in a datagrid.I have created a form with two text boxes, a search button and a datagrid. The two text boxes are txtFName.text and txtLName.Text. On clicking btnSearch I want to be able to run a search to the SQL database for specific records.So far I have been sucessful in doing so with a listbox but I would prefer to have the data populating in a datagrid as it is more cleaner.

Here is the working code for displaying searched data in a listbox: Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click

[Code]...

View 6 Replies

Searching File For Text?

May 28, 2011

I'm trying to make a script that searches for multiple .TXT files in a directory, and then searches the text of each file for a matching string(ie. "turtles"). It will search each file for the word "turtles". I've been on google trying to figure this out for a while, I'm guessing StreamReader is the way to go?

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim l_Dir As IO.DirectoryInfo
l_Dir = New IO.DirectoryInfo(MyPath)

[code]....

View 3 Replies

Searching Text File?

Sep 7, 2011

in vba i would use vlookup on an excel table. How do you search a text file in vb.net that is formatted like this

ES,2
C,3
EC,4

I want to search for the two letter string and retrieve the integer that follows the comma

View 3 Replies

Reading A Very Large Text File?

Jan 30, 2012

My problem is I have very large text files (approx 2GBs+).They have records in them based in one per line.Each line is not the same length and the data can be different lengths all the time.I am currently reading the file line by line, then splitting the data by common characters in the records. To process the full file it currently takes 3hours. This is way too slow for its purpose.

View 4 Replies

Reading Large Text File?

Jul 6, 2011

I've a problem reading text file using StreamReader. The file have between 500 000 and 1 000 000 lines.When I try to read it in a cycle, I get an error. That's why I've tried the StreamReader.ReadToEnd method. It worked fine. I've get the entire contents of the file in one string. So far everything is okay, but I've a small problem searching this huge string. I have to reformat the string to my desired format. I'll try to be more specific: The format of the input file is as follows:

50471100 8 2 6 5 0<LF><CR>
00000016 365442 12231<LF><CR>
00000026 112166 31133<LF><CR>
<end>

[Code]...

View 7 Replies

Text File Searching And File Path Retrieval

May 1, 2011

Im trying to get a list of all the text files present (there file paths) in a certain folder (lets say C:\Users\podypodpod\Desktop\textfiles) and then add them to the list box (lb_Entrys)

ive manage to find this code to get all text files from the desktop , but i cant manage to edit it so i can give an actual filepath for it to search

CODE:

View 2 Replies

Open File Via Searching In The Text?

Feb 16, 2012

I need to open a file everyday which is located in the V drive However the file renames itself daily such as DAA123 DAA128 So I cannot do a Data Refresh What I need to do is create a Macro to search the text document and if it prices PRICES365 and as at todays date Then it opens?

View 9 Replies

Searching Text File From Certain String?

Feb 1, 2010

I've got two text files. The first has got a list of certain keywords. Each one if these keywords are fed into a combobox. Now, when I choose one of the items from this combobox, I want to search the other textfile for the same keyword and read from that point to the next keyword. And then feed each line into a listbox. Perhaps I should use an INI-file for this purpose, doesn't really matter for me.

The textfiles have this structure;
Textfile1:
London
Oslo
New York
Hamburg
Amsterdam

The second textfile has this structure;
Textfile2:
'London'
Apples
Oranges
Pears

'Oslo'
Pasta
Salami
Monkeyballs

'New York'
Dada
Duda
Dadadish

Is this possible? The reason I want to do it this way is to create a fully dynamic system. One which relies fully on whatever information is stored in these textfiles. I'm gonna build pretty complex strings from these results later on. So far, I've got this to read the first file and add each line to the combobox:

Dim oReadMenuFunction as System.IO.StreamReader
oReadMenuFunction = IO.File.OpenText("textfile1.txt")
Do While oReadMenuFunction.Peek <> -1
Dim LineIn as String = oReadMenuFunction.ReadLine()
Combobox.Items.Add(LineIn)
Loop

View 2 Replies

Searching Things Out Of Text File

Jan 6, 2011

I'm trying to get help or idea how to get certain things out of text file. I don't know even if it's possible, but I hope so.[code]I need to get that number what is after /kick "nr". Also I need to get last /kick "nr".

View 8 Replies

Formatting :: Reformat A Large Text File?

Dec 10, 2011

I am faced with a rather large text file (200-400 lines)The file displays a lot of data however the problem is that it is not lined up. The data at the moment resembles this

Column1 Column2 Column3 Column4
Bobby Fisher Virginia Rural
Willis Johnson Oklahoma City

[code].....

View 1 Replies

Use Of Backgroundworker While Open A Large Text File?

Apr 3, 2010

How to Use of Backgroundworker while open a large text file

View 3 Replies

[2008] Reading A Very Large Text File

Feb 1, 2009

The following code suppose to:

1. Read line-by-line a txt file with more than 500,000 lines, (each line 521 characters long)

2. extract an ID No from the line

3. query from a database for LCCIStatus

4. concatenate the value of LCCIStatus to the line

5. write the line to sample.txt

My problem is, this code works perfectly with the test file of 8000 lines but fail with the actual files which have over 500,000 lines. FYI, the test file contains data which I cut and paste from the actual file.

[Code]...

View 5 Replies

Finding A Match When Searching Text File?

Jan 13, 2011

I've been writing a socket application in which the client sends a user/pass combination which the server compares to a local text file. I'm only hacvin a problem with a small section where I have a do loop which does this comparison:(the string 'fromclient' has been defined earlier, as the information was received from the client)

fromfile As String
Dim sr As StreamReader = File.OpenText("C:PASS.txt")
Do While sr.Peek <> -1

[code]....

View 2 Replies

Ini - Searching For A Specific String In A Text File ?

May 18, 2012

There's an INI file that I want to access and read information from. This is the complete content of the INI file in question: http:[url]....I believe it is because of the [ ] tags in that INI file. Because they work if I remove the tags.My program has a bunch of comboboxes, trackbars and checkboxes. These items will be filled by the information taken from the INI file.For instance, ini file has these lines;

bCrosshairEnabled=1
bDoDepthOfField=0
bFXAAEnabled=1[code]...

Example: I want the checkbox8 in my form to get checked if bFXAAEnabled has a value of 1 or unchecked if it is 0.

View 5 Replies

Searching Then Reading A Line In A Text File?

Mar 15, 2012

I need to be ble to know how to search a text file in VB for a particular line and then display it. the files I'm trying to use are set up as: ID, Name, Address, Birthday, Pay-Roll TypeSo I need to know how to search the file for the ID number and then display the rest of that line

View 16 Replies

When Searching A Text File / How To Be Sure It ONLY Searches Through Text File ONCE

Jan 18, 2012

I am searching a large text file for a word user inputs. When I test the following code, the app is searching the text file more than 1 X. I only need it to search the text file from beginning to end 1X. Then return the queried results.[code]

View 3 Replies

VS 2010 - Reading Text File And Returning Values To Textbox

Apr 17, 2011

I've a got a homework assignment that chooses one of four values in a list box, stores it in a text file. Secondly, on the display click event it should access the text file, read the line, store it in a variable and then display the totals in a text box. Works sort of fine except that it doesn't display the totals correctly. Code for both buttons is below. The variable are assigned in the mainform (Tried also in the display button and didn't change anything). The save button works fine and stores fine in the text file, it's just the reading that's the problem.

Private Sub saveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles saveButton.Click
'save the new vote choices to a file
Dim votes As IO.StreamWriter
votes = IO.File.AppendText("votes.txt")
Dim voteSelected As String = CStr(commercialListBox.SelectedIndex)
[Code] .....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved