I am trying to accomplish this problem:
write an appication that inputs a sentace from user (assume no punctuation), then determines and displays the non-duplicate words in alphabetical order. Treat upper and lowercase the same. [can use String method Split with no arguments, as in sentence.Split() to break a sentence into an array of Strings containing the individual words. By default, Split uses spaces as delimiters. Use String method ToLower in the Select and Order By clauses of your LINQ query to obtain the lowercase version of each word.]
so far this is what i have:
am i on the right track? if not what am i doing wrong. If I am on the right track, what am i missing?
write an appication that inputs a sentace from user (assume no punctuation), then determines and displays the non-duplicate words in alphabetical order. Treat upper and lowercase the same. [can use String method Split with no arguments, as in sentence.Split() to break a sentence into an array of Strings containing the individual words. By default, Split uses spaces as delimiters. Use String method ToLower in the Select and Order By clauses of your LINQ query to obtain the lowercase version of each word.]
so far this is what i have:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Dim sWords() As String = Split(TextBox1.Text, " ") 'two counters to compare all words to eachother For iFirstCounter As Integer = 0 To UBound(sWords) For iSecondCounter As Integer = 0 To UBound(sWords) 'If we are looking at different words (different counter numbers) 'and the words are the same, set the second one to nothing If iFirstCounter <> iSecondCounter And _ sWords(iFirstCounter) = sWords(iSecondCounter) Then sWords(iSecondCounter) = "" End If Next Next 'run by each word from the array For Each sWord As String In sWords 'if the word is something, then add the word to the text and add a space at the end If sWord <> "" Then TextBox1.Text &= sWord & " " End If Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'clear the text box TextBox1.Text = "" End Sub End Class
am i on the right track? if not what am i doing wrong. If I am on the right track, what am i missing?