Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cleaning text boxes


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.../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 heAboutHomework HelpShakespeareHomewor
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

__________________________________

--
jasonsweene
-----------------------------------------------------------------------
jasonsweeney's Profile: http://www.excelforum.com/member.php...nfo&userid=522
View this thread: http://www.excelforum.com/showthread.php?threadid=47777

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Cleaning text boxes

Hi Jason,

Try:

original_text = Application.Clean(original_text)


---
Regards,
Norman



"jasonsweeney"
wrote in message
news:jasonsweeney.1x6n2d_1129781113.3461@excelforu m-nospam.com...

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

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

" You are heAboutHomework HelpShakespeareHomework
HelpShakespeareEssentialsShakespeare FAQsQuotationsSoliloquy
AnalysisElizabethan Glossary Shakespeare TimelineShakespeare
OffersShakespeare Plays Shakespeare Movie BBC Shakespeare Shakespeare
Videos William Shakespeare What are offers?Articles & ResourcesStudent
"

Note that the there is a hard-return after "Homework" on the first
line. I need to remove this. The text needs to end up as one large
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

___________________________________


--
jasonsweeney
------------------------------------------------------------------------
jasonsweeney's Profile:
http://www.excelforum.com/member.php...fo&userid=5222
View this thread: http://www.excelforum.com/showthread...hreadid=477772



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default font for pasted text in text boxes - Excel 2007 MS OFFICE USER EIT Excel Discussion (Misc queries) 0 March 25th 10 09:01 PM
User Form Text Boxes - Copy format of text boxes NDBC Excel Discussion (Misc queries) 3 July 2nd 09 02:02 AM
How do I link Text Boxes to Cells, not Cells to Text Boxes? Ebby Excel Worksheet Functions 1 May 15th 07 11:31 PM
Pivot Tables - cleaning up combo boxes history Nacho Excel Discussion (Misc queries) 1 July 27th 05 08:59 PM
Cleaning Text James[_14_] Excel Programming 1 November 18th 03 09:33 PM


All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"