Cleaning text boxes

J

jasonsweeney

I need to "scrub" text entered into a text box. By "scrub" I mean tha
I want to remove certain unwanted characters and formatting. My cod
(below) effectively removes all unwanted characters, but certai
carriage returns, etc., are not removed. Any suggestions?

To test the code, I go to the following website
http://shakespeare.about.com/library/weekly/aa011801a.htm, pres
cntrl-A to select all text, copy, and then paste from clipboard into
textbox in a userform. This is first few lines of the output:

" You are here:About>Homework Help>ShakespeareHomewor
HelpShakespeareEssentialsShakespeare FAQsQuotationsSoliloqu
AnalysisElizabethan Glossary Shakespeare TimelineShakespear
OffersShakespeare Plays Shakespeare Movie BBC Shakespeare Shakespear
Videos William Shakespeare What are offers?Articles & ResourcesStuden
"

Note that the there is a hard-return after "Homework" on the firs
line. I need to remove this. The text needs to end up as one larg
paragraph with no carriage returns, paragraphs breaks, etc....
___________________________
The code (userform, textbox1,commandbutton1)

Private Sub CommandButton1_Click()
Dim original_text, Revised_text, chk_char, firsts_string As String
Dim Character_count As Integer
original_text = TextBox1.Value
'
'
'Clean Text
Character_count = Len(original_text)
For i = 1 To Character_count
chk_char = Asc(Mid(original_text, i, 1))
If chk_char > 31 And chk_char < 126 Then
Revised_text = Revised_text & Mid(original_text, i, 1)
End If
Next i
TextBox1.Value = Revised_text

End Sub

__________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top