Results 1 to 8 of 8

Thread: [RESOLVED] spacses in rich text

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Resolved [RESOLVED] spacses in rich text

    hello

    any body knows how can i add a space befor and after any symbol (such as (,) . - ....etc) in a rich text box

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: spacses in rich text

    Do you mean like while typing or when you allready have the text and you would like to change it?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: spacses in rich text

    i mean if i alredy have the text

  4. #4
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: spacses in rich text

    VB Code:
    1. Dim i As Long
    2.     With RichTextBox1
    3.         .SelStart = 0
    4.             For i = -1 To Len(.Text)
    5.                 .SelStart = .SelStart + 1
    6.                 .SelText = " "
    7.             Next i
    8.     End With

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: spacses in rich text

    thanks gavio for your fast reply

    but this code adds spaces between all letters and i whant to add spaces between the symbols like ? \ . ;

    for example if the text was :
    Hello, where are you? please (call)

    it will be:
    Hello , where are you ? please ( call )



  6. #6
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: spacses in rich text

    VB Code:
    1. With RichTextBox1
    2.         .Text = Replace(.Text, ",", " , ")
    3.         .Text = Replace(.Text, "?", " ? ")
    4.         .Text = Replace(.Text, "\", " \ ")
    5.         .Text = Replace(.Text, ".", " . ")
    6.         .Text = Replace(.Text, ";", " ; ")
    7.         .Text = Replace(.Text, "(", " ( ")
    8.         .Text = Replace(.Text, ")", " ) ")
    9.     End With

    EDIT: Or..
    VB Code:
    1. RichTextBox1.Text = Replace(Replace(Replace(Replace(Replace(Replace(Replace(RichTextBox1.Text, _
    2.          ",", " , "), "?", " ? "), "\", " \ "), ".", " . "), ";", " ; "), "(", " ( "), ")", " ) ")
    Last edited by jcis; Aug 22nd, 2006 at 02:18 PM.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    131

    Re: spacses in rich text

    Jcis

    thanks alot thats it

  8. #8
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: spacses in rich text

    bear in mind you'll lose any formatting if you use jcis's method

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width