Hi romanos,

Here is a function you can try that uses the String.Split Method and the Dictionary Class (I have marked the code that you might want to edit yourself using ++++++++'s):
VB.NET Code:
  1. Public Class Form1
  2.  
  3.     Private Function WordPercentage(ByVal AllWords As Boolean, Optional ByVal WordToFind As String = Nothing) As String
  4.  
  5.         'If you specify False to matching AllWords and don't provide a WordToFind then there can be no results
  6.         If Not (AllWords) AndAlso WordToFind = Nothing Then Return Nothing
  7.  
  8.         'Create a lookup table that can store every word found in the RichTextBox and the number of times it occurs
  9.         Dim UniqueWords As New Dictionary(Of String, Integer)
  10.         'If you only want the percentage for a specific word then set the word in the Table. (No further entries will be added)
  11.         If Not (AllWords) Then UniqueWords.Add(WordToFind, 0)
  12.  
  13.         'Split the TichTextBox using the Space char. This will leave you with a string array containing all the words
  14.         Dim RTBWords() As String = RichTextBox1.Text.Split(New Char() {" "c}, StringSplitOptions.RemoveEmptyEntries)
  15.  
  16.         'Calculate the total number of words in the RichTextBox (needed to calculate the percentage)
  17.         Dim NoWords As Integer = RTBWords.Count
  18.  
  19.         'If there are no words then exit the sub
  20.         If NoWords = 0 Then Return Nothing
  21.  
  22.         For Each Word As String In RTBWords
  23.  
  24.             '+++++++ Remove this line if you do not want to allow case-insensitive matches +++++++
  25.             Word = Word.ToLower
  26.  
  27.             'Check if the current word was found in the UniqueWords lookup table
  28.             If UniqueWords.ContainsKey(Word) Then
  29.                 'If it was then add 1 to the word count
  30.                 UniqueWords.Item(Word) += 1
  31.             Else
  32.                 'If you want to find the percentage of all the words in the RichTextBox then add each word into the Lookup table
  33.                 If AllWords Then UniqueWords.Add(Word, 1)
  34.             End If
  35.  
  36.         Next Word
  37.  
  38.  
  39.         '++++++++++++ Edit the Output to suit your own needs ++++++++++++
  40.  
  41.         'Compile the results using stringbuilder
  42.         Dim Output As New System.Text.StringBuilder("The following Words were found in the RichTextBox:" & vbCrLf & vbCrLf)
  43.         'For every word that was found in the RichTextBox
  44.         For Each Entry As KeyValuePair(Of String, Integer) In UniqueWords
  45.             'Append the word to the output and the calculated percentage
  46.             Output.AppendLine(Entry.Key & ": " & ((Entry.Value * 100) / NoWords).ToString & "%")
  47.         Next Entry
  48.  
  49.         '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  50.  
  51.         'Return the Output
  52.         Return Output.ToString
  53.  
  54.     End Function
  55.  
  56. End Class
You can implement this function in your code using something like:
VB.NET Code:
  1. Private Sub YourSub()
  2.     'If you want to get the percentage of all the words in the RichTextBox:
  3.     Dim AllWordsPercentage As String = WordPercentage(True)
  4.     If Not (AllWordsPercentage) = Nothing Then MessageBox.Show(AllWordsPercentage) Else MessageBox.Show("No results were found")
  5.     'If you want to get the percentage of a particular word (e.g. "music"):
  6.     Dim SpecificWordPercentage As String = WordPercentage(False, "music")
  7.     If Not (SpecificWordPercentage) = Nothing Then MessageBox.Show(SpecificWordPercentage) Else MessageBox.Show("No results were found")
  8. End Sub
Hope this helps