|
-
Sep 17th, 2000, 09:38 PM
#1
Thread Starter
Lively Member
say you've got a string: "hi bob, whats up?" and want to remove "bob, whats up?" and get stuck with "hi ". How?!
thanks!
___________________________
Chris
-
Sep 17th, 2000, 09:42 PM
#2
Fanatic Member
if it's the first three chars then
Code:
Dim str As String
Dim newstr as String
str = "Hi , Bob whats up"
newstr = Left(str,3)
Otherwise use the instr function to find char possition!
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Sep 18th, 2000, 01:42 AM
#3
Conquistador
also this, for instr function
Code:
Dim myStr As String
myStr = "hi bob, whats up?"
MsgBox Left(myStr, InStr(1, myStr, "b", vbTextCompare) - 2)
-
Sep 18th, 2000, 03:12 AM
#4
Or try this...
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
Hope you like it
-
Sep 18th, 2000, 03:55 AM
#5
Conquistador
but your code doesn't help with the parsing, you are just replacing it with what you want.
-
Sep 18th, 2000, 01:59 PM
#6
replacing with nothing is the same as stripping some chars off, isn't it?
-
Sep 18th, 2000, 03:03 PM
#7
For the simple purpose of retrieving the text, I think running it through a function will slow it down a little.
-
Sep 18th, 2000, 05:46 PM
#8
Nitro-> Why would you say so? Unless he's processing many of these strings, it's much more Legitmet to use the Left function.
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
|