Current location: Hot Scripts Forums » Programming Languages » Visual Basic » replacing new lines with spaces


replacing new lines with spaces

Reply
  #1 (permalink)  
Old 05-12-04, 10:06 PM
PaPPy PaPPy is offline
Newbie Coder
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
replacing new lines with spaces

Here's what I am doing, I am converting a paragraph thats in a text box to a listbox thats one charcter wide. So the list box now shows the paragraph vertically one letter by letter. Well I ran into one problem. If there is a line break (someone hit enter) it shows up as the character "|". This causes my program to crash out. Below is the code I am using to conver from paragraph to single character list. If someone can show me a line to add to it or if I have to add a whole seperate statement to delete the line break.

Private Sub btnConvert_Click()
Dim str As String
Dim char As String
List1.Clear 'ListBox used for displaying splitten characters.
str = Text1.Text 'TextBox used for getting i/p string
For i = 1 To Len(str) Step 1
char = Mid(str, i, 1)
If char <> " " Then
List1.AddItem char
End If
Next i
End Sub

(Thanks gopinath_alr for the code)


-PaPPy
Reply With Quote
  #2 (permalink)  
Old 05-13-04, 12:56 AM
gopinath_alr gopinath_alr is offline
Newbie Coder
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
hi pappy,
when the user press enter button, Line feed and carriage return are added to the textbox string.
so we can check whether the character is equal to Line feed or carriage return. If it is, we simply exclude the characters not to be added to list box.
here is the code with modified syntax.

Private Sub Command1_Click()
Dim str As String
Dim char As String
List1.Clear 'ListBox used for displaying splitten characters.
str = Text1.Text 'TextBox used for getting i/p string
For i = 1 To Len(str) Step 1
char = Mid(str, i, 1)
If char <> " " And char <> vbLf And char <> vbCr Then 'Modified code
List1.AddItem char
End If
Next i
End Sub

have a nice time.
bye.
Reply With Quote
  #3 (permalink)  
Old 05-13-04, 08:47 AM
kebo kebo is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by gopinath_alr
hi pappy,
when the user press enter button, Line feed and carriage return are added to the textbox string.
so we can check whether the character is equal to Line feed or carriage return. If it is, we simply exclude the characters not to be added to list box.
here is the code with modified syntax.

Private Sub Command1_Click()
Dim str As String
Dim char As String
List1.Clear 'ListBox used for displaying splitten characters.
str = Text1.Text 'TextBox used for getting i/p string
For i = 1 To Len(str) Step 1
char = Mid(str, i, 1)
If char <> " " And char <> vbLf And char <> vbCr Then 'Modified code
List1.AddItem char
End If
Next i
End Sub

have a nice time.
bye.
After you define str you could use the REPLACE function to change the vbCRFL's into a space
i.e.
replace(str,vbCRLF," ")
kevin
Reply With Quote
  #4 (permalink)  
Old 05-13-04, 08:01 PM
PaPPy PaPPy is offline
Newbie Coder
 
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for the help


next topic is here i need help on
http://www.programmingtalk.com/showthread.php?t=9087
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wht does these script lines mean? karthik_vina Script Requests 0 04-14-04 06:52 AM
check for spaces in username field darkcarnival PHP 9 01-23-04 03:33 PM
Clearing white spaces in database lordmerlin PHP 9 10-27-03 02:31 AM
Free .ASP 'tell a friend' email form needed, preferably with multiple friend spaces retrocom Script Requests 0 08-23-03 12:44 PM
replacing certain parts of certain strings in text files Archbob PHP 0 07-29-03 04:23 PM


All times are GMT -5. The time now is 01:20 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.