Ask a Question related to ASP Database, Design and Development.
-
Darren #1
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
-
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... -
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.... -
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... -
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... -
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... -
Chris Hohmann #2
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...a> Hi,
> I have a Field (Entries) from an Access DB that i want to only returnsplit> certain number of words, say 20. Though I do not want to have a word20 words or 20 letters?> 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. )
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
-
Bob Barrows #3
Re: Retrive a set number of full words from a field question?
Darren wrote:
There's no way to do this in a query. You are going to need to return the> 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. )
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
-
Darren #4
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...Hi Chris,> "Darren" <darren@REMOVETHISdarren-craig.co.uk> wrote in message
> news:eI73d9Q5DHA.2696@TK2MSFTNGP09.phx.gbl...> a> > Hi,
> > I have a Field (Entries) from an Access DB that i want to only return> split> > certain number of words, say 20. Though I do not want to have a word>> > 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
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
-
Aaron Bertrand - MVP #5
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
-
Darren #6
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...Would this then mean that all I have to do then is drop the variable 'str'>
> 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," ")
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
-
Darren #7
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...with> Well, in SQL Server, if it's a VARCHAR(8000), you could certainly do itthose> a UDF. But shouldn't, as performance would likely be unacceptable.
>
> Another idea for the OP, instead of saying 20 words (especially since"supercalifragilisticexpialidocious> twenty words could be "a a a a a ..." or....")> supercalifragilisticexpialidocious supercalifragilisticexpialidociousThanks for the link Aaron, I'll check it out.> you use number of characters, and chop off at the latest space within:
> [url]http://www.aspfaq.com/2398[/url]
the> 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 returnthe> > entire contents of the field to asp, and use vbscript code to extract>> > 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
-
Bob Barrows #8
Re: Retrive a set number of full words from a field question?
Aaron Bertrand - MVP wrote:
If it was SQL Server, I would have had another suggestion ... :-)> 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.That InStrRev function was not available in A97 - that should be noted in>
> 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]
>
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



Reply With Quote

