Results 1 to 11 of 11

Thread: Simple Word Editing (Resolved)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Resolved Simple Word Editing (Resolved)

    A progam to change the following to the following.

    word_word__

    word__

    __word

    would become

    word_word

    word

    word

    i need it to remove all the underscores the begining and the ends of the words. But if a word has an underscore in the middle that stays.

    Get me ?
    Last edited by Ricky1; Oct 2nd, 2005 at 04:43 PM.
    Im Learning !!!!

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Simple Word Editing

    Where are the words? In a multiline textbox, or rtf, or in a listbox?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Simple Word Editing

    sorry in a listbox.
    Im Learning !!!!

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Simple Word Editing

    and where are they going? into another listbox, or the same one?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Simple Word Editing

    same one.
    Im Learning !!!!

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Simple Word Editing

    Code:
    Public Sub RemoveRealName()
    
    Dim I As Long
    Dim Word As String
    For I = 0 To list1.ListCount - 1
    X = 0
    
    Do While X < 31
    
    If Left(list1.List(I), 1) = "_" Then
        Word = Right(list1.List(I), Len(list1.List(I)) - 1)
    End If
    
    If Right(list1.List(I), 1) = "_" Then
        Word = Left(list1.List(I), Len(list1.List(I)) - 1)
    End If
    
    X = X + 1
    
    Loop
    
    list1.List(I) = list1.List(I) & " - " & Word
    
    Next I
    
    End Sub
    ok i have worked it out to make it remove the scores but now im trying to do this.
    make it loop and change all the scores but then make it do the following.

    Word was __Rick_

    it changes to Rick by remove the scores like above. But then list(i) becomes original word then a dash and the new word.

    __Rick_ - Rick

    I tried the code above but it only loops once before it changes list(I) any help ?
    Im Learning !!!!

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Simple Word Editing

    i need to make it finish the loop before it changes list(i) but it won't do the loop first.

    Getting really annoyed lol
    Im Learning !!!!

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Simple Word Editing

    Try this. It leaves multiple underlines in the middle of a word, but you didn't say anything about that.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.   Dim x As Integer, arr() As String, t As Integer
    5.   t = List1.ListCount - 1
    6.   ReDim arr(t)
    7.   For x = 0 To t
    8.     arr(x) = List1.List(x)
    9.   Next x
    10.   List1.Clear
    11.   For x = 0 To t
    12.     List1.AddItem strip(arr(x))
    13.   Next x
    14. End Sub
    15.  
    16. Function strip(w As String) As String
    17.   Dim x As Integer, b As Integer
    18.   Dim str As String, e As Integer
    19.   For x = 1 To Len(w)
    20.     If Mid(w, x, 1) <> "_" Then
    21.        b = x
    22.        Exit For
    23.     End If
    24.   Next x
    25.  For x = Len(w) To 1 Step -1
    26.     If Mid(w, x, 1) <> "_" Then
    27.        e = x
    28.       Exit For
    29.     End If
    30.   Next x
    31.   strip = Mid$(w, b, e - b + 1)
    32. End Function
    33.  
    34. Private Sub Form_Load()
    35.   List1.AddItem "word_word__"
    36.   List1.AddItem "word__"
    37.   List1.AddItem "__word"
    38.   List1.AddItem "word_word__"
    39. End Sub

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Simple Word Editing

    well looking at my code could ya change it to make it work ?
    Im Learning !!!!

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Simple Word Editing

    Sure, just have to change one line.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.   Dim x As Integer, arr() As String, t As Integer
    5.   t = List1.ListCount - 1
    6.   ReDim arr(t)
    7.   For x = 0 To t
    8.     arr(x) = List1.List(x)
    9.   Next x
    10.   List1.Clear
    11.   For x = 0 To t
    12.     List1.AddItem strip(arr(x))
    13.   Next x
    14. End Sub
    15.  
    16. Function strip(w As String) As String
    17.   Dim x As Integer, b As Integer
    18.   Dim str As String, e As Integer
    19.   For x = 1 To Len(w)
    20.     If Mid(w, x, 1) <> "_" Then
    21.        b = x
    22.        Exit For
    23.     End If
    24.   Next x
    25.  For x = Len(w) To 1 Step -1
    26.     If Mid(w, x, 1) <> "_" Then
    27.        e = x
    28.       Exit For
    29.     End If
    30.   Next x
    31. [COLOR=Red]  strip = w & " - " & Mid$(w, b, e - b + 1)
    32. [/COLOR]End Function
    33.  
    34. Private Sub Form_Load()
    35.   List1.AddItem "word_word__"
    36.   List1.AddItem "word__"
    37.   List1.AddItem "__word"
    38.   List1.AddItem "word_word__"
    39.   List1.AddItem "__Rick__"
    40. End Sub

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Simple Word Editing (Resolved)

    That takes care of it, doesn't it?

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