I am making a program for school where the user has to choose a chapter to learn. when the user has choosen one i want to use a text file where all the words are in: for example
In the program you choose chapter 5 then the program has to open 5.txt and convert it into variables.
In the text file are to words on one line seperated by a comma. then in the program the first word has to come on a place and you have to fill in the translation in a textbox. then the program has to check it.
sorry for my bad english, it is because i am from the NL

Let me see if I have this.

  1. The user selects a file from a list
  2. The file contains pairs of words. The first is in one language, the second in another
  3. The program displays the first word and a textbox for the user to type the translation
  4. The program compares the translated word to the correct word that was in the file

Input file looks like

hond,dog
venster,window
huis,house

NL as in Netherlands?

commented: Thanks for helping +0

yes thats right. do you have a solution for me?

oh wait the first step is wrong, you have to click a button

It would make more sense (to me) to have the chapters in a combobox. Selecting a new chapter would automatically open the file. You said this was for school so I am assuming it is an assignment. We don't do other people's homework for them. However, we will give help with problems you may be having. For example, are you having trouble with

  1. the file input
  2. parsing the lines in the file
  3. storing the file contents in a data structure
  4. presenting the words to the user
  5. checking the user entry against the file

I asked about NL because my grandparents came to Canada from there in the 1890s.

commented: thanks for helping +0

It is for school but i started it myself, it wasn't a assignement (i am still in secondary school) it is for latin. I am from the NL thats right. For the program i dont know where and how to start. first i had a old version you can download it here:
https://www.box.com/s/f49aa434a2e5a708a555
but it was hard to edit the words and stuff like that. now other people (like freinds) can help me with making lists of words

if you need or like to i can also send you the code and stuff.

If you have a ComboBox named cbxChapters you can populate it as follows (assumes you have all of the chapters in one folder and the files are named Chapter-##.txt and myFolder is a string variable set to the name of the folder containing the files).

cbxChapters.Items.Clear()

For Each file In My.Computer.FileSystem.GetFiles(myFolder, FileIO.SearchOption.SearchTopLevelOnly, "Chapter*.txt")
    cbxChapters.Items.Add(System.IO.Path.GetFileNameWithoutExtension(file))
Next

You can step through each line in the chapter file by

For Each line As String In System.IO.File.ReadAllLines(filename)
    Dim words() As String = line.Split(",")

Now you have the word in one language in words(0) and the translated word in words(1). It should be a simple matter to present the first word in a label or readonly textbox and wait for the user to enter the guess in the other. I'd have a "Submit Guess" button and also allow the user to press ENTER to submit the guess.

okay thanks for the help!!!
maybe i need some more help later on!

Feel free to return if you get stuck.

so in this code:

For Each file In My.Computer.FileSystem.GetFiles(myFolder,FileIO.SearchOption.SearchTopLevelOnly, "Chapter*.txt")
    cbxChapters.Items.Add(System.IO.Path.GetFileNameWithoutExtension(file))

can i make the filepath so that it looks for the folder in the place where the program stands?

i dont understand how to add the filepath

The current directory (folder) can be determined by

My.Computer.FileSystem.CurrentDirectory

By default this is the folder containing the executable but this could change if you specify a different "Start In:" folder in a program shortcut.

it isnt working
maybe i have made some sort of spelling error? This is my program code:

    Dim myfolder As String
    For Each file In My.Computer.FileSystem.GetFiles(myFolder, FileIO.SearchOption.SearchTopLevelOnly, "Chapter*.txt")
        cbxChapters.Items.Add(System.IO.Path.GetFileNameWithoutExtension(file))
        myfolder = My.Computer.FileSystem.CurrentDirectory
    Next

and i have a folder called TXT with Chapter11.txt and Chapter12.txt

Try the following.

    Dim myfolder As String = My.Computer.FileSystem.CurrentDirectory
    myfolder = System.IO.Path.Combine(myfolder,"TXT")

    For Each file In My.Computer.FileSystem.GetFiles(myFolder, FileIO.SearchOption.SearchTopLevelOnly, "Chapter*.txt")
        cbxChapters.Items.Add(System.IO.Path.GetFileNameWithoutExtension(file))
    Next

The first statement gets the current folder.The next one combines that with "TXT", assuming that TXT is in fact a folder under the current one.

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.