Results 1 to 2 of 2

Thread: Characters(VBA Access97)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Location
    Ireland
    Posts
    11

    Characters(VBA Access97)

    How do you read through a string in VB, and copy portions into another variable

    eg

    given the string "Name___:Helen No.___:1234"


    how do you put, lets say recst.name="Helen" and recst.num="1234" (recst is just a recst)
    Have a nice day

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    If VBA will allow it you can use SPLIT

    Dim MyArr() AS string

    MyArr = Split("this:is:the:string",":")

    .. will fill the array with

    MyArr(0)= this
    MyArr(1) = is
    MyArr(2) = the ... etc etc

    Without the SPLIT function you will need to play with the INSTR function ..

    Dim StartPos as Integer
    StartPos = Instr("This is: the string",":")

    Startpos will return the position of the first ":" in the string. You can then use the left/right/mid commands to extract either side.

    LeftStr = Left("This is: the string",StartPos)
    RightStr = Mid("This is: the string",StartPos)
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

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