Results 1 to 3 of 3

Thread: Another string question (you'd think I'd be learning by now!)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    UK
    Posts
    66
    I have a string - with a name and a code - how can I extract just the name Eg:

    Simon : 5353DF
    should give 'Simon'

    Debbie : 3535GH
    should give 'Debbie'

    Any ideas?

    Simon

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    If you always use a colon as seperator, you can search for the first colon. eg
    sName = "Simon : 5353DF "
    MsgBox Trim(Left(sName, InStr(sName, ":") - 1))

  3. #3
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308
    Hi, Simon.

    Try this code:

    Dim str As String
    Dim NewStr As String

    str = "Simon : 5353DF"

    NewStr = Mid(str, 1, InStr(1, str, ":") - 1)
    MsgBox NewStr

    Larisa

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