Here is a function I just wrote that will capitalize the first letter of each new sentence. It looks for the ending punctuation followed by a space(or two, if you specify it to do so via "spaceNum" integer = 2 instead of 1), and then finds the character afterwards and makes it UCase$. It also has the option of(if you have a huge string to work with) do it with DoEvents, letting you do other tasks, or without it(default is without it):

VB Code:
  1. Public Function strSentenceCapitals(strString As String, Optional spaceNum As Integer = 1, Optional withDoEvents As Boolean = False) As String
  2.  
  3.     If strString = "" Then Exit Function
  4.    
  5.     'Check for all end-of-sentence punctuation
  6.     If Not InStrB(strString, ". ") > 0 Then
  7.         If Not InStrB(strString, "? ") > 0 Then
  8.             If Not InStrB(strString, "! ") > 0 Then
  9.                 Exit Function
  10.             End If
  11.         End If
  12.     End If
  13.    
  14.    
  15.     If spaceNum < 1 Then spaceNum = 1
  16.     If spaceNum > 1 Then spaceNum = 2
  17.    
  18.    
  19.         Dim searchStrTxt As Integer
  20.         Dim strCmpare As String
  21.         Dim strRplc As String
  22.         Dim strModified As String
  23.         Dim strFirstChr As String
  24.    
  25.    
  26.         If withDoEvents = True Then
  27.             GoTo doFreeProc
  28.         Else
  29.             GoTo doHoldProc
  30.         End If
  31.        
  32.     Exit Function
  33.  
  34.  
  35.  
  36. 'Do with DoEvents
  37. doFreeProc:
  38.    
  39.     strModified = strString
  40.     strFirstChr = UCase(Mid$(strModified, 1, 1))
  41.     strModified = strFirstChr & Mid$(strModified, 2)
  42.    
  43.     If spaceNum = 1 Then
  44.         'Search for single-spaced punctuation
  45.         For searchStrTxt = 1 To Len(strString) - 1
  46.             DoEvents
  47.             strCmpare = Mid$(strModified, searchStrTxt, 2)
  48.                 If strCmpare = ". " Then
  49.                     strRplc = Mid$(strString, searchStrTxt, 3)
  50.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  51.                 End If
  52.                
  53.                 If strCmpare = "? " Then
  54.                     strRplc = Mid$(strString, searchStrTxt, 3)
  55.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  56.                 End If
  57.                
  58.                 If strCmpare = "! " Then
  59.                     strRplc = Mid$(strString, searchStrTxt, 3)
  60.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  61.                 End If
  62.         Next searchStrTxt
  63.     Else
  64.         'Search for double-spaced punctuation
  65.         For searchStrTxt = 1 To Len(strString) - 1
  66.             DoEvents
  67.             strCmpare = Mid$(strModified, searchStrTxt, 2)
  68.                 If strCmpare = ". " Then
  69.                     strRplc = Mid$(strString, searchStrTxt, 3)
  70.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  71.                 End If
  72.                
  73.                 If strCmpare = "? " Then
  74.                     strRplc = Mid$(strString, searchStrTxt, 3)
  75.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  76.                 End If
  77.                
  78.                 If strCmpare = "! " Then
  79.                     strRplc = Mid$(strString, searchStrTxt, 3)
  80.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  81.                 End If
  82.         Next searchStrTxt
  83.     End If
  84.        
  85.         'Assign new string
  86.         strSentenceCapitals = strModified
  87.    
  88.     Exit Function
  89.  
  90.  
  91.  
  92. 'Do without DoEvents
  93. doHoldProc:
  94.    
  95.     strModified = strString
  96.     strFirstChr = UCase(Mid$(strModified, 1, 1))
  97.     strModified = strFirstChr & Mid$(strModified, 2)
  98.    
  99.         If spaceNum = 1 Then
  100.         'Search for single-spaced punctuation
  101.         For searchStrTxt = 1 To Len(strString) - 1
  102.             'DoEvents
  103.             strCmpare = Mid$(strModified, searchStrTxt, 3)
  104.                 If strCmpare = ".  " Then
  105.                     strRplc = Mid$(strString, searchStrTxt, 4)
  106.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  107.                 End If
  108.                
  109.                 If strCmpare = "?  " Then
  110.                     strRplc = Mid$(strString, searchStrTxt, 4)
  111.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  112.                 End If
  113.                
  114.                 If strCmpare = "!  " Then
  115.                     strRplc = Mid$(strString, searchStrTxt, 4)
  116.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  117.                 End If
  118.         Next searchStrTxt
  119.     Else
  120.         'Search for double-spaced punctuation
  121.         For searchStrTxt = 1 To Len(strString) - 1
  122.             'DoEvents
  123.             strCmpare = Mid$(strModified, searchStrTxt, 3)
  124.                 If strCmpare = ".  " Then
  125.                     strRplc = Mid$(strString, searchStrTxt, 4)
  126.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  127.                 End If
  128.                
  129.                 If strCmpare = "?  " Then
  130.                     strRplc = Mid$(strString, searchStrTxt, 4)
  131.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  132.                 End If
  133.                
  134.                 If strCmpare = "!  " Then
  135.                     strRplc = Mid$(strString, searchStrTxt, 4)
  136.                     strModified = Replace$(strModified, strRplc, UCase$(strRplc))
  137.                 End If
  138.         Next searchStrTxt
  139.     End If
  140.        
  141.         'Assign new string
  142.         strSentenceCapitals = strModified
  143.  
  144. End Function


You would call it like this, for single-spaced sentences(ie. "Hi. My name is Joe"):


VB Code:
  1. Text1.Text = strSentenceCapitals(Text1.Text)
  2. 'Or...
  3. Text1.Text = strSentenceCapitals(Text1.Text, 1)

The "1" specifies the number of spaces between sentences. It defaults at "1" so you don't really have to specify it if you're looking for single-spaced sentences. To look for double-space sentences, replace the "1" with "2" or any number higher than 1. The function will auto set the value to "2" if you specify an integer higher than 2, that way it's not looking for a 5-spaced sentence if you mis-type it.

Also, to do it with DoEvents(to allow activity while the function is running), you would call it like so:

VB Code:
  1. Text1.Text = strSentenceCapitals(Text1.Text, 1, True)

The default is "False"(ie. Do without "DoEvents") so you'd have to specify it as "True" if you want to use DoEvents. If not, you don't have to specify and you can call the function either of the 2 above ways specified.


Just thought this simple function might help some folks out ;D

Enjoy!