String Munging

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Laphan

    String Munging

    Hi All

    Need another favour.

    I have an Access memo field that contains a list of single random words that
    are separated by a single space. What I need to do is extract a random word
    from this list 8 times so that I can have the following to play with:

    1stRandomWord.2 ndRandomWord

    3rdRandomWord.4 thRandomWord

    5thRandomWord.6 thRandomWord

    7thRandomWord.8 thRandomWord

    I doing a Access DB to ASP page, so any ASP-compliant VB example code would
    be really appreciated.

    Rgds

    Laphan


  • Laphan

    #2
    Re: String Munging

    Many thanks MN

    Much appreciated.

    Rgds Laphan

    MN <imthedaddynah@ hotmail.com> wrote in message
    news:adb8f7dd.0 307100822.686da 053@posting.goo gle.com...
    "Laphan" <news@FrozenMol es.co.uk> wrote in message
    news:<bei28i$o5 b$2@sparta.btin ternet.com>...[color=blue]
    > Hi All
    >
    > Need another favour.
    >
    > I have an Access memo field that contains a list of single random words[/color]
    that[color=blue]
    > are separated by a single space. What I need to do is extract a random[/color]
    word[color=blue]
    > from this list 8 times so that I can have the following to play with:
    >
    > 1stRandomWord.2 ndRandomWord
    >
    > 3rdRandomWord.4 thRandomWord
    >
    > 5thRandomWord.6 thRandomWord
    >
    > 7thRandomWord.8 thRandomWord
    >
    > I doing a Access DB to ASP page, so any ASP-compliant VB example code[/color]
    would[color=blue]
    > be really appreciated.
    >
    > Rgds
    >
    > Laphan[/color]


    Read you word list into a string variable and use the VB split
    function to break the words apart at the " " character.

    lstrWordList = lobjRst("<name of memo field>")
    lstrWordArr = split(lstrWordL ist," ")

    response.write( lstrWordArr(0) & "." & lstrWordArr(1) & "<br>")

    Remembering that in VB(Script) array indexes start at 0.

    If you want to make it more generic then ubound(<array variable name>)
    can be used to get the upper bound of the array so you can do your
    processing in a loop.

    If the delimeter specified as argument 2 of the split function is not
    found in the string the whole string will be in element 0 of the
    array.

    Enjoy.


    Comment

    Working...