|
-
Jun 6th, 2005, 02:35 PM
#1
Thread Starter
Hyperactive Member
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
-
Jun 6th, 2005, 02:39 PM
#2
Re: Remove " : "
You can replace it with a space, or whatever you want like this:
VB Code:
if instr(List1.list(i),":") > 0 then
list1.list(i) = replace(list1.list(i), ":" " ")
endif
-
Jun 6th, 2005, 02:42 PM
#3
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:
Dim I As Integer
Dim J As Integer
Dim intArrLen As Integer
intArrLen = List.ListCount
Dim strTheArr() As String
ReDim strTheArr(intArrLen)
For I = 0 To Screen.FontCount - 1
strTheArr(I) = List.List(I)
Next I
List.Clear
For J = 0 To UBound(strTheArr)
strTheArr(J) = Replace(strTheArr(J), ":", "")
List.AddItem strTheArr(J)
Next J
Or use dglienna's method which is shorter anyway... You meat me too it again... 
Cheers,
RyanJ
-
Jun 6th, 2005, 02:50 PM
#4
Re: Remove " : "
Won't just removing the ":" work for you?
-
Jun 6th, 2005, 02:57 PM
#5
Re: Remove " : "
 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
-
Jun 6th, 2005, 03:04 PM
#6
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.
-
Jun 6th, 2005, 03:28 PM
#7
Thread Starter
Hyperactive Member
Re: Remove " : "
yes if the line has the : in it, then i want the whole line removing.
-
Jun 6th, 2005, 03:31 PM
#8
Re: Remove " : "
 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:
Dim I As Integer
For I = 0 To List1.ListCount
If InStr(List1.List(i), ":") > 0 Then
List1.RemoveItem I
End If
Next I
Cheers,
RyanJ
-
Jun 6th, 2005, 03:35 PM
#9
Thread Starter
Hyperactive Member
Re: Remove " : "
cheers, wil give it a go in a min
-
Jun 6th, 2005, 03:48 PM
#10
Thread Starter
Hyperactive Member
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.
-
Jun 6th, 2005, 03:59 PM
#11
Re: Remove " : "
 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:
Private Sub Command3_Click()
Dim I As Integer
For I = List1.ListCount - 1 To 0 Step -1
If InStr(List1.List(I), ":") > 0 Then
List2.AddItem List1.List(I)
List1.RemoveItem I
End If
Next I
List1.Refresh
List2.Refresh
End Sub
Cheers,
RyanJ
Last edited by sciguyryan; Jun 6th, 2005 at 04:07 PM.
-
Jun 6th, 2005, 04:04 PM
#12
Re: Remove " : "
dont forget to always loop in reverse when there is a possibility of removing more than one item.
VB Code:
For I = List1.ListCount - 1 To 0 Step -1
casey.
-
Jun 6th, 2005, 04:06 PM
#13
Re: Remove " : "
Good point, will change thart 
Cheers,
Ryanj
-
Jun 6th, 2005, 04:08 PM
#14
Thread Starter
Hyperactive Member
Re: Remove " : "
CHeers, Got It Working, Thanks Alot u2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|