Results 1 to 8 of 8

Thread: Super easy, just forgot.. help..

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    99
    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

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    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]

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    also this, for instr function
    Code:
    Dim myStr As String
    myStr = "hi bob, whats up?"
    MsgBox Left(myStr, InStr(1, myStr, "b", vbTextCompare) - 2)

  4. #4
    Guest
    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

  5. #5
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    but your code doesn't help with the parsing, you are just replacing it with what you want.

  6. #6
    Guest
    replacing with nothing is the same as stripping some chars off, isn't it?

  7. #7
    Guest
    For the simple purpose of retrieving the text, I think running it through a function will slow it down a little.

  8. #8
    Guest
    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
  •  



Click Here to Expand Forum to Full Width