I need to concatenate characters from a text document to create a phrase. I understand the concept of concatenating from text boxes on a form, but not concatenating characters from another file. This isn't my assignment, but it is the concept I need to understand.

A text document that reads "The cow jumped over the moon as it moved from earth to venus." From that I need to use the characters from the phrase to create the word "mover over". Am I able to read from the text document or do I copy the text into the program and do some sort of character count? Any advice/example would be greatly appreciated.

You have several options, the Mid Statememnt will replace a string within a string with characters from another string. You can use the InStr function to find the index of the string you want to replace. The Len Function can be used to find the length of a string.

If you read the text line from the file with a line input statement and assign it to a variable you can then create an array of words from that with the split function.
Dim saWords() as string
Line Input #1, WordLine
saWords = split(WordLine," ")
saWords(0) is the first word, saWords(1) is the second, etc. so then you can re-write the phrase by moving the words.

Can I use the same concept with letters instead of words?

The string functions will allow a string of any length even 1 character

Problem still not solved. Any other suggestions?

Show the code you're using and explain what's not working and how specifically you want it to work.

Unfortunately the problem is that I can't even figure out where to start. I've tried dozens of combinations and nothing is remotely close to correct.

Private Sub lblPhrase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblPhrase.Click

    Dim myString As String() = "The cow jumped over the moon as it moved from earth to venus."

    lblPhrase.Show()
End Sub

You're still not giving enough info. You say you want to get characters from a textfile and build a phrase. How are you determining the phrase? Is the text file words and sentences? Or random letters? If you already have a string with the phrase why do you need to build it from a file?

You say you've tried different things. What have you tried, and in each case how is it not working?

You've been shown how to get words as strings from a text file. You also been shown functions that allow you to break down those string into characters. Do you have a problem following that? If so what is it?

I'm sorry that I'm not understanding. It seems like this should be simple, but I'm completely lost.

This example is not my assignment, but it is the theory I need to understand. I have a phrase and from that phase, I have to extract individual letters to form words. I don't need to extract full words or even continuous letters. It doesn't matter if I pull from the text file or place the phrase as string and pull from it.

If the phase is "The cow jumped over the moon as it moved from earth to venus." I need to extract a series of letters to form a new word. Example "when", where the 'w' would come from the word 'cow", the 'h' from the word 'The', the 'e' would come from the word "over, and finally the 'n' would come from the word 'venus'. I then need the word "when" to appear in a text box.

All the examples I find are nowhere near what I'm trying to do.

I'm not there, but at least I have a few lines that aren't total crap! Instead of having the strSelectPhrase be a portion of the full phrase, how do I isolate individual letters?

Private Sub lblPhrase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblPhrase.Click

    Dim strSelectPhrase As String
    Dim strFullPhrase As String
    strFullPhrase = "The cow jumped over the moon as it moved from earth to venus."
    strSelectPhrase = strFullPhrase.Substring(6)
    lblPhrase.Text = strSelectPhrase
End Sub

Got it! Now, is there a better way?

Private Sub lblPhrase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblPhrase.Click

    Dim strSelectPhrase As String
    Dim strFullPhrase As String
    strFullPhrase = "The cow jumped over the moon as it moved from earth to venus."
    strSelectPhrase = strFullPhrase.Chars(6) & strFullPhrase.Chars(1) & strFullPhrase.Chars(2) & strFullPhrase.Chars(27)
    lblPhrase.Text = strSelectPhrase
End Sub

That should do it. Only 1 thing to think about if you want to change the phrase, it means hardcoding it in. Also part of the problem of solving this, is you're in the wrong forum. You should be in the VB.NET forum. That's one of the reasons why you'll find people harping about code, so that this kind of thing can be caught easier.

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.