Link to home
Start Free TrialLog in
Avatar of ksg313
ksg313

asked on

Pulling sentences from text string

Is there a more compact way to get the first 3 sentences (if there are 3 sentences - some have less) from a paragraph of text?

                                                               strMessage = RemoveHTML(rsData("Message"))
                        nPos1 = InStr(strMessage, ".")
                        nPos2 = InStr(nPos1 + 1, strMessage, ".")
                        nPos3 = InStr(nPos2 + 1, strMessage, ".")

                        if nPos1 > 0 then
                             strMessage1 = Mid(strMessage, 1, nPos1)
                        end if
                        if nPos2 > nPos1 + 1 then
                              strMessage1 = Mid(strMessage, nPos1 + 1, nPos2 - nPos1)
                        end if
                        if nPos3 > nPos2 + 1 then
                              strMessage1 = Mid(strMessage, nPos2 + 1, nPos3 - nPos2)
                        end if
                        if strMessage1 <> "" then
                              strMessage = strMessage1
                        end if
ASKER CERTIFIED SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm glad that I could help.  Thanks for the grade, the points and the fun question.

bol