Results 1 to 7 of 7

Thread: String content

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Wellington, NZ
    Posts
    267

    String content

    Hi

    This is an easy one, and I think I will be embarased when (if) I get the answer.

    I've got a string of 3 fields, delimited by colons. How do I get the posibion of these colons so I can extract the fields with a MID ?

    Thanks
    Robert

  2. #2
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: String content

    Why dont you just use a Split() statement and split the words into an array?

    Dim yArray
    sentence = one:two:three
    yArray = Split(sentence,":")
    yArray(0)= one
    yArray(1)= two
    yArray(2)= three
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: String content

    A more generalized solution would be

    VB Code:
    1. Dim strParts() As String
    2. Dim lngIndex As Long
    3.  
    4. strParts = Split(YOUR_STRING, ":")
    5.  
    6. For lngIndex = 0 To UBound(strParts)
    7.     Debug.Print strParts(lngIndex)
    8. Next

  4. #4
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: String content

    I just wrote the yarray(0) etc to show what the array would be filled like. thats good code MartinLiss. I might have to change how I loopp through my arrays, lol.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Wellington, NZ
    Posts
    267

    Re: String content

    Thanks guys.

    After I posted my question, I remembered the Instr. I didn't know about Split. But I do now.

    Thanks
    Robert

  6. #6
    Fanatic Member neicedover1982's Avatar
    Join Date
    Jun 2005
    Posts
    566

    Re: String content

    If your question is answered, make your thread as resolved.
    Kevin | New England Iced Over | http://www.kevincawleyjr.com

  7. #7

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