Is it possible to have string in a richtextbox checked for pronouns and then make them all upper case? I'm a little familiar with the class method 'ToUpper' but don't know how to go from there. I have a richtextbox on my form and I want to check for any person's names. If there is a name, it has to be all Caps before it's created on the Excel Document

Dani AI

Generated

Short answer: treat this as "detect then transform." Since you clarified you want proper names upper-cased, the pragmatic solution is to ship a name dictionary (common first/ and last-names), scan the RichTextBox text token-by-token with a regex, and convert matches to ALL CAPS before exporting to Excel. This follows the points made by and : pronouns are trivial to enumerate, proper names need a list or a more advanced NER step.

A compact VB.NET pattern you can use (load your name file once at startup, one name per line):

Imports System.IO
Imports System.Text.RegularExpressions
Imports System.Globalization

' load names (one per line) into a case-insensitive HashSet for O(1) lookups
Dim nameSet As New HashSet(Of String)(File.ReadAllLines("names.txt"), StringComparer.OrdinalIgnoreCase)

Private Function UppercaseNames(text As String) As String
    Dim pattern As String = "\b[\p{L}\-']+\b" ' words including hyphens/apostrophes
    Return Regex.Replace(text, pattern, Function(m As Match)
                                           Dim w = m.Value
                                           If nameSet.Contains(w) Then
                                               Return w.ToUpper(CultureInfo.InvariantCulture)
                                           End If
                                           ' treat single-letter initials as names
                                           If w.Length = 1 AndAlso Char.IsLetter(w(0)) Then
                                               Return w.ToUpper(CultureInfo.InvariantCulture)
                                           End If
                                           Return w
                                       End Function)
End Function

Notes and tips: keep the name list updated (include common surnames, first names, titles like Mr/Mrs, and suffixes). For multi-word names, scan adjacent tokens and upper-case them when a sequence looks like a name (name -> initial -> name). Use a HashSet for speed and RegexOptions.Compiled if processing large text. Use ToUpperInvariant or a culture-aware ToUpper depending on your target users. Expect false positives/negatives: automated detection is heuristic. For best UX, highlight the changes and let users confirm before writing to Excel, or consider integrating a proper named-entity recognizer if you need higher accuracy.

Recommended Answers

All 4 Replies

Do you mean pronouns or do you mean proper nouns. In one case you want words like I, me, he, they, etc. This can be done by using a regular expression to identify the enumerated strings bounded by non-letters. However, if you mean proper nouns then I can't see how that can be done because it is impossible to build a list of all names to look for.

you're not clear with your question

Is it possible to have string in a richtextbox checked for pronouns ...
... and I want to check for any person's names

and i agree with Reverend_Jim, there can be tons of names and you'll never know if the name is just made up. Whereas in pronouns you can list them then scan for them in the richtextbox

Proper nouns because if the user types a small dictation in the rich textbox, some users have forgotten to make the proper nouns/names in all caps. i.e. JOHN H DOE. I figured it was a long shot, but wanted to put that question out there and see. thanks guys.

Well, if you really want to, you can just include the famous names and the common ones just like in ms word.

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.