Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Default font for pasted text in text boxes - Excel 2007 | Excel Discussion (Misc queries) | |||
User Form Text Boxes - Copy format of text boxes | Excel Discussion (Misc queries) | |||
How do I link Text Boxes to Cells, not Cells to Text Boxes? | Excel Worksheet Functions | |||
Pivot Tables - cleaning up combo boxes history | Excel Discussion (Misc queries) | |||
Cleaning Text | Excel Programming |