Results 1 to 14 of 14

Thread: Remove " : " Resolved

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Resolved Remove " : " Resolved

    Ok i have a word file which has got all messed up with the character " : " but the think is i need to remove the whole line. So is there a way i can say like

    Code:
    Dim Grrr As String
    Grrr = List.List(i)
    
    Then If Grrr Contains :
    Remove Grrr
    Hope this is clear.
    I need it to remove the Whole Line. If possible Remove them from List1, and add the ones it removes into List2 so i can check it has removed the right ones.

    Please Help Meeeeeee
    Last edited by Ricky1; Jun 6th, 2005 at 04:17 PM. Reason: Resolved
    Im Learning !!!!

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

    Re: Remove " : "

    You can replace it with a space, or whatever you want like this:


    VB Code:
    1. if instr(List1.list(i),":") > 0 then
    2.   list1.list(i) = replace(list1.list(i), ":" " ")
    3. endif

  3. #3
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Remove " : "

    You'll have to read all the lines into an array.
    Scan through them all checking for the presence of the : using the InStr function.
    The use the Replace funciton to remove the :
    The clear the listbox and reload the string

    VB Code:
    1. Dim I As Integer
    2.     Dim J As Integer
    3.     Dim intArrLen As Integer
    4.     intArrLen = List.ListCount
    5.     Dim strTheArr() As String
    6.     ReDim strTheArr(intArrLen)
    7.     For I = 0 To Screen.FontCount - 1
    8.         strTheArr(I) = List.List(I)
    9.     Next I
    10.     List.Clear
    11.     For J = 0 To UBound(strTheArr)
    12.         strTheArr(J) = Replace(strTheArr(J), ":", "")
    13.         List.AddItem strTheArr(J)
    14.     Next J

    Or use dglienna's method which is shorter anyway... You meat me too it again...

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

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

    Re: Remove " : "

    Won't just removing the ":" work for you?

  5. #5
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Remove " : "

    Quote Originally Posted by dglienna
    Won't just removing the ":" work for you?

    If you mean me then I did not know you could directly modify items in a list or combobox the way you did

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

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

    Re: Remove " : "

    No, I re-read his post, and wonder if he wanted to remove a line, which consist of who knows how many items.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Remove " : "

    yes if the line has the : in it, then i want the whole line removing.
    Im Learning !!!!

  8. #8
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Remove " : "

    Quote Originally Posted by Ricky1
    yes if the line has the : in it, then i want the whole line removing.
    In that case try this:

    VB Code:
    1. Dim I As Integer
    2. For I = 0 To List1.ListCount
    3.     If InStr(List1.List(i), ":") > 0 Then
    4.         List1.RemoveItem I
    5.     End If
    6. Next I

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Remove " : "

    cheers, wil give it a go in a min
    Im Learning !!!!

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Remove " : "

    Code:
    Private Sub Command3_Click()
    Dim I As Integer
    For I = 0 To List1.ListCount - 1
        If InStr(List1.List(I), ":") > 0 Then
            List2.AddItem I
            List1.RemoveItem I
        End If
    Next I
    
    End Sub
    thats my code, doens't seem to work tho
    suppose to remove List1(i) if it contains the character : .
    Remove it from list1 and add it to list2.
    Im Learning !!!!

  11. #11
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Remove " : "

    Quote Originally Posted by Ricky1
    thats my code, doens't seem to work tho
    suppose to remove List1(i) if it contains the character : .
    Remove it from list1 and add it to list2.
    It should be:

    VB Code:
    1. Private Sub Command3_Click()
    2.     Dim I As Integer
    3.     For I = List1.ListCount - 1 To 0 Step -1
    4.         If InStr(List1.List(I), ":") > 0 Then
    5.             List2.AddItem List1.List(I)
    6.             List1.RemoveItem I
    7.         End If
    8.     Next I
    9.     List1.Refresh
    10.     List2.Refresh
    11. End Sub

    Cheers,

    RyanJ
    Last edited by sciguyryan; Jun 6th, 2005 at 04:07 PM.
    My Blog.

    Ryan Jones.

  12. #12
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: Remove " : "

    dont forget to always loop in reverse when there is a possibility of removing more than one item.
    VB Code:
    1. For I = List1.ListCount - 1 To 0 Step -1

    casey.

  13. #13
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Remove " : "

    Good point, will change thart

    Cheers,

    Ryanj
    My Blog.

    Ryan Jones.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Remove " : "

    CHeers, Got It Working, Thanks Alot u2
    Im Learning !!!!

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