Extracting meaningful values from free-form text is notoriously difficult.
If you're absolutely certain that each value will be on its own line, that the line will start with the correct label, and the label and value will be separated with a colon, then you
might be able to use a
Regular Expression[
^] to extract the values.
Dim lastName As String = Nothing, firstName As String = Nothing, race As String = Nothing, sex As String = Nothing
Dim pattern As New Regex("^\s*(?<label>[^:]+)\s*:\s*(?<value>.+)\s*\r?$", RegexOptions.Multiline)
Dim matches As MatchCollection = pattern.Matches(RichTextBox1.Text)
For Each match As Match In matches
Dim label As String = match.Groups("label").Value
If String.Equals(label, "Last Name", StringComparison.OrdinalIgnoreCase) Then
lastName = match.Groups("value").Value
Else If String.Equals(label, "First Name", StringComparison.OrdinalIgnoreCase) Then
firstName = match.Groups("value").Value
Else If String.Equals(label, "Race", StringComparison.OrdinalIgnoreCase) Then
race = match.Groups("value").Value
Else If String.Equals(label, "Sex", StringComparison.OrdinalIgnoreCase) Then
sex = match.Groups("value").Value
End If
Next