|
-
Jan 6th, 2003, 12:38 PM
#1
Thread Starter
Member
Remove() Function?
Hi guys,
I'm just wondering if anybody has written a Remove Function. I'm getting a bit sick of having to use Mid() all the time, and I believe it's slowing down my program a little.. unfortunately, I don't have the know-how yet to write myown remove function.. 
Thanks,
P.S - What I basically am looking for is something that would work similiar to this:
str = "bah!"
newstr = Remove(str,"b")
Which would just return 'ah!' 
Thanks heaps everybody
-
Jan 6th, 2003, 12:58 PM
#2
Addicted Member
You could use Replace to do the same thing as your example here:
VB Code:
test = "bah!"
test = Replace(test, "b", "")
msgbox test
-
Jan 6th, 2003, 01:02 PM
#3
Thread Starter
Member
That's what I was originally doing, but I came across a problem..
What if the string was something like "baboon"? It'd change it to "aoon" instead of just "aboon".. any ideas?
Thanks
-
Jan 6th, 2003, 01:11 PM
#4
Sleep mode
Well , how about using Left( ) Function ?
-
Jan 6th, 2003, 01:22 PM
#5
Or do you just want to strip out the first occurence of a character?
VB Code:
Private Function Remove(ByVal RemoveFrom As String, ByVal ToRemove As String, _
Optional Count As Integer = 1) As String
If Not (Count >= 1) Then Err.Raise 5
Remove = Replace(RemoveFrom, ToRemove, "", Count:=Count)
End Function
Private Sub Command1_Click()
MsgBox Remove("baboon", "b")
End Sub
I believe that is case sensitive, but it can easily be changed not to be.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
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
|