Retrive a set number of full words from a field question?

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Retrive a set number of full words from a field question?

    Hi,
    I have a Field (Entries) from an Access DB that i want to only return a
    certain number of words, say 20. Though I do not want to have a word split
    in two, i.e. :

    'I wandered lonely as a clou.....'

    Any one have any tips on how to achieve this?
    I am using ASP(VBScript. )


    --
    Best Regards
    Darren

    [url]www.yourdesignz.co.uk[/url]
    [url]www.darren-craig.co.uk[/url]


    Darren Guest

  2. Similar Questions and Discussions

    1. null indication in number field
      would like to indicate when field was not writen to OR if a null value was posted in a number field. is there any way to write 'null' or other...
    2. COutn the number of words
      how can i count how many words have i written in a text area??? Like taking an example ... i am writing in this textarea of microsoft usergroup....
    3. Number Field is 7 or 10 digits, only
      USC is switching their student id numbers now from 7 digits to 10 digits. It was just two years ago when they required us to not ask for SS# as an...
    4. Auto Increment a number field
      I have a memo field (History) and a number field (Count). What I require is that when the history field is updated then the count field will...
    5. Increment a number in a text field
      I'm having problems getting a text field to automatically increment, exp. when you add a record to a form, it should automatically give a new id...
  3. #2

    Default Re: Retrive a set number of full words from a field question?

    "Darren" <darren@REMOVETHISdarren-craig.co.uk> wrote in message
    news:eI73d9Q5DHA.2696@TK2MSFTNGP09.phx.gbl...
    > Hi,
    > I have a Field (Entries) from an Access DB that i want to only return
    a
    > certain number of words, say 20. Though I do not want to have a word
    split
    > in two, i.e. :
    >
    > 'I wandered lonely as a clou.....'
    >
    > Any one have any tips on how to achieve this?
    > I am using ASP(VBScript. )
    20 words or 20 letters?

    If it's 20 letters:

    Left([Entries],InStr(20,[Entries]," "))

    If it's 20 words then I don't really understand the question.

    HTH
    -Chris


    Chris Hohmann Guest

  4. #3

    Default Re: Retrive a set number of full words from a field question?

    Darren wrote:
    > Hi,
    > I have a Field (Entries) from an Access DB that i want to only return
    > a certain number of words, say 20. Though I do not want to have a
    > word split in two, i.e. :
    >
    > 'I wandered lonely as a clou.....'
    >
    > Any one have any tips on how to achieve this?
    > I am using ASP(VBScript. )
    There's no way to do this in a query. You are going to need to return the
    entire contents of the field to asp, and use vbscript code to extract the
    first 20 words. One way would be to use the split and join functions:

    str = rs("entries")
    ar = split(str, " ")
    redim preserve ar(19)
    str = join(ar," ")

    HTH,
    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

  5. #4

    Default Re: Retrive a set number of full words from a field question?

    "Chris Hohmann" <nospam@thankyou.com> wrote in message
    news:OjwTFKR5DHA.1816@TK2MSFTNGP12.phx.gbl...
    > "Darren" <darren@REMOVETHISdarren-craig.co.uk> wrote in message
    > news:eI73d9Q5DHA.2696@TK2MSFTNGP09.phx.gbl...
    > > Hi,
    > > I have a Field (Entries) from an Access DB that i want to only return
    > a
    > > certain number of words, say 20. Though I do not want to have a word
    > split
    > > in two, i.e. :
    > >
    > > 'I wandered lonely as a clou.....'
    > >
    > > Any one have any tips on how to achieve this?
    > > I am using ASP(VBScript. )
    >
    > 20 words or 20 letters?
    >
    > If it's 20 letters:
    >
    > Left([Entries],InStr(20,[Entries]," "))
    >
    > If it's 20 words then I don't really understand the question.
    >
    > HTH
    > -Chris
    Hi Chris,
    I have a field called 'entries'. It is used as part of a Blog
    application that I have written. In this field there could be between 20 -
    1000 words, or more.

    On the front page of my site, I have a sidebar, in which I want to display
    the title of the last 2 entries in the Blog, along with the first 20 or so
    words from the actual blog entry (Entries field). I don't want the whole
    text of the blog entry, this would act as a teaser, if you will. I would
    then have a 'Read more...' link to take the user to a page which would
    display the full text of the blog entry along with the ability to add
    comments.
    What I need is some kind of routine that will only bring back the first
    20 -- full words-- ( or however many is suitable for the space constraints
    of my sidebar) of the 'Entries' field of a given record.

    I hope I have explained things more clearly this time Chris.

    Many Thanks
    Darren








    Darren Guest

  6. #5

    Default Re: Retrive a set number of full words from a field question?

    Well, in SQL Server, if it's a VARCHAR(8000), you could certainly do it with
    a UDF. But shouldn't, as performance would likely be unacceptable.

    Another idea for the OP, instead of saying 20 words (especially since those
    twenty words could be "a a a a a ..." or "supercalifragilisticexpialidocious
    supercalifragilisticexpialidocious supercalifragilisticexpialidocious ...")
    you use number of characters, and chop off at the latest space within:
    [url]http://www.aspfaq.com/2398[/url]

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:uRTxkWR5DHA.2760@TK2MSFTNGP09.phx.gbl...
    > Darren wrote:
    > > Hi,
    > > I have a Field (Entries) from an Access DB that i want to only return
    > > a certain number of words, say 20. Though I do not want to have a
    > > word split in two, i.e. :
    > >
    > > 'I wandered lonely as a clou.....'
    > >
    > > Any one have any tips on how to achieve this?
    > > I am using ASP(VBScript. )
    >
    > There's no way to do this in a query. You are going to need to return the
    > entire contents of the field to asp, and use vbscript code to extract the
    > first 20 words. One way would be to use the split and join functions:
    >
    > str = rs("entries")
    > ar = split(str, " ")
    > redim preserve ar(19)
    > str = join(ar," ")
    >
    > HTH,
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Aaron Bertrand - MVP Guest

  7. #6

    Default Re: Retrive a set number of full words from a field question?

    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:uRTxkWR5DHA.2760@TK2MSFTNGP09.phx.gbl...
    >
    > There's no way to do this in a query. You are going to need to return the
    > entire contents of the field to asp, and use vbscript code to extract the
    > first 20 words. One way would be to use the split and join functions:
    >
    > str = rs("entries")
    > ar = split(str, " ")
    > redim preserve ar(19)
    > str = join(ar," ")
    Would this then mean that all I have to do then is drop the variable 'str'
    into my code to have the first 19 words from the 'entries' field?

    If so manmy thanks for that Bob. Looks so easy when you have someone who
    knows there stuff show you ;-)
    > HTH,
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >

    Darren Guest

  8. #7

    Default Re: Retrive a set number of full words from a field question?

    "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    news:OGr9PgR5DHA.2312@TK2MSFTNGP12.phx.gbl...
    > Well, in SQL Server, if it's a VARCHAR(8000), you could certainly do it
    with
    > a UDF. But shouldn't, as performance would likely be unacceptable.
    >
    > Another idea for the OP, instead of saying 20 words (especially since
    those
    > twenty words could be "a a a a a ..." or
    "supercalifragilisticexpialidocious
    > supercalifragilisticexpialidocious supercalifragilisticexpialidocious
    ....")
    > you use number of characters, and chop off at the latest space within:
    > [url]http://www.aspfaq.com/2398[/url]
    Thanks for the link Aaron, I'll check it out.
    > Aaron Bertrand
    > SQL Server MVP
    > [url]http://www.aspfaq.com/[/url]
    >
    >
    >
    >
    > "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    > news:uRTxkWR5DHA.2760@TK2MSFTNGP09.phx.gbl...
    > > Darren wrote:
    > > > Hi,
    > > > I have a Field (Entries) from an Access DB that i want to only return
    > > > a certain number of words, say 20. Though I do not want to have a
    > > > word split in two, i.e. :
    > > >
    > > > 'I wandered lonely as a clou.....'
    > > >
    > > > Any one have any tips on how to achieve this?
    > > > I am using ASP(VBScript. )
    > >
    > > There's no way to do this in a query. You are going to need to return
    the
    > > entire contents of the field to asp, and use vbscript code to extract
    the
    > > first 20 words. One way would be to use the split and join functions:
    > >
    > > str = rs("entries")
    > > ar = split(str, " ")
    > > redim preserve ar(19)
    > > str = join(ar," ")
    > >
    > > HTH,
    > > Bob Barrows
    > > --
    > > Microsoft MVP -- ASP/ASP.NET
    > > Please reply to the newsgroup. The email account listed in my From
    > > header is my spam trap, so I don't check it very often. You will get a
    > > quicker response by posting to the newsgroup.
    > >
    > >
    >
    >

    Darren Guest

  9. #8

    Default Re: Retrive a set number of full words from a field question?

    Aaron Bertrand - MVP wrote:
    > Well, in SQL Server, if it's a VARCHAR(8000), you could certainly do
    > it with a UDF. But shouldn't, as performance would likely be
    > unacceptable.
    If it was SQL Server, I would have had another suggestion ... :-)
    >
    > Another idea for the OP, instead of saying 20 words (especially since
    > those twenty words could be "a a a a a ..." or
    > "supercalifragilisticexpialidocious
    > supercalifragilisticexpialidocious supercalifragilisticexpialidocious
    > ...") you use number of characters, and chop off at the latest space
    > within: [url]http://www.aspfaq.com/2398[/url]
    >
    That InStrRev function was not available in A97 - that should be noted in
    your article.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139