This is my first VB class and I've always struggled with output, and I've been messing around and I can't get the right stuff to display. The code processes a sentence a user enters into an input box to display how many words, conjunctions, prepositions, articles, and other words there are.
The output list box is supposed to display something like this:
Sentence: Hello world (user entered example obv)
Number of words: 2
Conjunctions: ....... and so forth with "articles" and "other of words"
Code:'Declaration Section Dim input As String = "" While input.Length < 1 input = InputBox("Enter Sentence to process", "Loop Fun") End While Dim words() As String = input.Split(" ") Dim wordcount As Integer = words.Length Dim conjunctions As Integer Dim prepositions As Integer Dim articles As Integer Dim otherwords As Integer Dim fmtstr As String = "{0,-16} {1,-1}" 'Processing lstOutput.Items.Clear() Dim count As Integer While count < words.Length - 1 count += 1 Select Case words(count) Case "and" conjunctions += 1 Case "but" conjunctions += 1 Case "or" conjunctions += 1 Case "to" prepositions += 1 Case "over" prepositions += 1 Case "above" prepositions += 1 Case "under" prepositions += 1 Case "down" prepositions += 1 Case "up" prepositions += 1 Case "a" articles += 1 Case "an" articles += 1 Case "the" articles += 1 End Select End While otherwords = wordcount - conjunctions - prepositions - articles 'Output??? help!!




Reply With Quote