say you've got a string: "hi bob, whats up?" and want to remove "bob, whats up?" and get stuck with "hi ". How?!
thanks!
Printable View
say you've got a string: "hi bob, whats up?" and want to remove "bob, whats up?" and get stuck with "hi ". How?!
thanks!
if it's the first three chars then
Otherwise use the instr function to find char possition!Code:Dim str As String
Dim newstr as String
str = "Hi , Bob whats up"
newstr = Left(str,3)
also this, for instr function
Code:Dim myStr As String
myStr = "hi bob, whats up?"
MsgBox Left(myStr, InStr(1, myStr, "b", vbTextCompare) - 2)
Or try this...
Hope you like it :)Code:Option Explicit
Private Sub Form_Load()
Debug.Print DoIt("Hi, Bob what's up?")
End Sub
Private Function DoIt(S As String) as string
DoIt = Replace(S, ", bob what's up?", "", , , vbTextCompare)
End Function
but your code doesn't help with the parsing, you are just replacing it with what you want.
replacing with nothing is the same as stripping some chars off, isn't it?
For the simple purpose of retrieving the text, I think running it through a function will slow it down a little.
Nitro-> Why would you say so? Unless he's processing many of these strings, it's much more Legitmet to use the Left function.