Hi experts.
I'm in need for your help. is it able to create a software who can check if a text file contain a text for example

Words.txt has few words inside like: "work, job, play, study, go, house" and at Words1.txt have words like: " People, fun, jokes"

can the software pick People from Words1.txt and play from Words.txt?

like this is not possible I know but I was thinking for something like after the word at the .txt file have a description or tag. something like:

Ani      | Human, my friend, boy
Car      | Vecycle, object with 4 wheels
Play     | Enjoyment etc

the project pick only the word People not the tag or the description

is this able to do? months ago I saw someone who did something like this for a software who save data in MySQL, but not to make the software delay 0.5 seconds. All the data he save in .txt files with description but when open the software the "tag/description" was not shown, only the name.

Wait, you want to combine 3rd word from first file, and 1st word from second file? Can't you put word "play" as first word? Like,

Words.txt: "play, toy, tralala, DaniWeb"
Words2.txt "people, problem, potter, pancakes"

If you can do that, you can read the file one by one and saving their contents into variables, then you can tell VB.NET compiler to take the contents and split words by coma into continuous array. So example[0] will be "play", example[1] will be "toy" etc. . Do same for both files, and then echo each row (something like fileone[0] + filetwo[0]) and but put them into for loop. So it progresses.

Good luck!

lets say in both files have 100 words. after the tag I want the word come in the textbox.
it doesnt read text from the first till the end, but just take the header text like "play, tpy, tralala, DaniWeb" not the entire word like "DaniWeb | a forum who help programmers finding good solutions"

Your probably using | as you delimiter. You shouldnt.

Add something like * after the sentences then write code to read the content till it gets to that *

so you would have

DaniWeb | a forum to help programmers *
Play | a means to have fun *

then in your app code you make it find a word
and read till it sees a *

I used | as a example, Im trying to understand how to use the code so he will read only DaniWeb from DaniWeb | a forum to help programmers *

I have no idea how to do this... :/

found a great example how to say what I want to make. if I type in textbox1: "a good programmers forum" press enter or a button and the software search in the text file for tags * forum, good * etc
if find 1 it show the word who have the tag.

if can find this it would be very helpful in ALL WAYS for my project

Im still having difficulty understanding your requirement.

But try this:

    Public Function SplitWord(ByVal s As String) as String


    'Split string where there is a '|'

    Dim words As String() = s.Split(New String() {"|"})

    SplitWord = words

    End Function

You can call it and give it a string as a parameter

It should return the first word before the '|'

Meaning if you give it 'This | is a ball'

It would return 'this'

If you want it to give you all the words in the document one line at a time,
then we can do that too.

If anyone can better understand his requirement, please explain.

thanks for making that for me. but how to select the specific word? the word after the | is the tag of the word, the software check who have similar tags and
show that word to a textbox.

Im totally not understanding but i want to help. If you can find a different way of expressing yourself id be happy. If your better at a different language try describing your requirement in detail and use google to translate it.

Maybe that would help.

Im trying to make a software who read a .txt file with few words and each word have few tags something like
Ani #friend #human #male
Car #machine
BMW #car
etc..

for example in textbox1 I type "Cars" and after press button1
in textbox2 it show all the words who have the tag car

dont know how to explain in a better way..

You keep changing formats. First you said

Ani      | Human, my friend, boy

Now the format is

Ani #friend #human #male

The first thing you have to do is nail down a format. I'm guessing that what you have is a file like

Ani      | Human, my friend, boy
Car      | Vehicle, object with 4 wheels
Truck    | Vehicle, object with 4 wheels
Play     | Enjoyment
Man      | Human, male
Woman    | Human, female

That would be easy to parse. You could use Split on | to separate the word from the tags, then Split on , to separate the individual tags.

Based on that, when you type a tag into a textbox the program displays all words from the file that have that tag. For example, if you enter Vehicle, the program will display

Car
Truck

Is that correct?

I changed because was unable to understand for some people.

but how to understand the word what word to put. as I said at the last exapmle I give. if I put at textbox1 the word "car" (the software seach this as tag)
in textbox 2 it show results of words who have the some tag. for example like "BMW, Benz, Audi"

Yeah Reverend Jim, I think that is what he wants. I understand now.

@altjen - Must the code be in VB?

yes Toby and yes Jim that is what Im trying to do but was not explaining well.

Try this:

Module Module1

    Sub Main()
        Dim FileName As String 

        FileName = "C:\Users\Toby\Desktop\daniweb.txt"

        Dim TextLine As String

        If System.IO.File.Exists(FileName) = True Then

        Dim objReader As New System.IO.StreamReader( FileName )

        Do While objReader.Peek() <> -1

        TextLine = TextLine & objReader.ReadLine() & vbNewLine

        Loop

        Console.WriteLine(TextLine)
        Dim aryTextFile() As String
        Dim numOfLines As Integer 
        Dim input As String

        Console.WriteLine("what do you wanna find")
        input = Console.ReadLine()

        aryTextFile = TextLine.Split("*")

        numOfLines= UBound(aryTextFile)       

        For counter = 0 to numOfLines

        Dim pos As Integer = InStr(aryTextFile(counter),input)

        If pos <> Nothing AndAlso pos <> -1 

                    Console.WriteLine(aryTextFile(counter))



        End If

        Next


        Else

        MsgBox("File Does Not Exist")

        End If

        Console.ReadLine()
    End Sub


End Module

This would return the whole line with the word.

Its a console app so you can add the GUI yourself.

so if you have

Ani | #friend #human #male *
Car | #machine *
BMW | #car *
Toyota | #car *
James | #human #male *

and search for Machine you will get

Car | #machine

use the split function i gave you earlier to make it gibe just the word before the '|'

I used the trailing * to split the lines before checking. So you have to use that format in your text file.

Hope that helps.

commented: helpful +2

thanks but Im a bit confused, where to type machine? you did not add anything for textbox
also textline show as warning. why?

Capture.JPG

Create a new console app project.

Paste the code.

Change the file path.

Run the application.

Then you will be prompted to type.

Alternatively, just replace

input = Console.ReadLine()

with

input = "machine"

thanks for all your help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.