473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Appending an s for plural

I posted this from work but I don't think it got through so apologies if
this is duplicated.

I'm trying to avoid the old chestnut where you go something like:

Span = lngDays & " day(s)"

so that an s gets appended only if it's more than 1, I came up with this:

Span = lngDays & " day" & String(Abs(Sgn(lngDays - 1)), "s")

which seems to take care of minus numbers and makes 0 a plural, just
wondering if anyone's got a neater solution.
Nov 13 '05 #1
2 2179
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I use the IIf() function:

Span = lngDays & " day" & IIf(Abs(lndDays)<>1,"s", "")

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQSO0BIechKqOuFEgEQK3+QCfdSYuRvMAbYPv0GMpdj8MJC zjd7QAoM5z
wSvPwgrxZINrSWNn5EaF1iEg
=rdnD
-----END PGP SIGNATURE-----
Trevor Best wrote:
I posted this from work but I don't think it got through so apologies if
this is duplicated.

I'm trying to avoid the old chestnut where you go something like:

Span = lngDays & " day(s)"

so that an s gets appended only if it's more than 1, I came up with this:

Span = lngDays & " day" & String(Abs(Sgn(lngDays - 1)), "s")

which seems to take care of minus numbers and makes 0 a plural, just
wondering if anyone's got a neater solution.


Nov 13 '05 #2
Trevor Best escreveu:
I posted this from work but I don't think it got through so apologies if
this is duplicated.

I'm trying to avoid the old chestnut where you go something like:

Span = lngDays & " day(s)"

so that an s gets appended only if it's more than 1, I came up with this:

Span = lngDays & " day" & String(Abs(Sgn(lngDays - 1)), "s")

which seems to take care of minus numbers and makes 0 a plural, just
wondering if anyone's got a neater solution.


Maybe a trickiest (?) way:

Span = lngDays & " day" & String(-(Abs(lngDays) <> 1), "s")

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: denisb | last post by:
hello all, for a search engine, I'm looking for a regexp than can do the job it is just (!) a 's' problem (frequent in french) : I have a field 'thesaurus' in a table MySQL (3.23.56) ; I...
3
by: MLH | last post by:
I have a query, qryAppend30DayOld260ies that attempts to append records to tblCorrespondence. When run, it can result in any of the following: appending no records, appending 1 record or appending...
2
by: Steve - DND | last post by:
Just wondering if anyone out there has any code to convert a plural word to it's singular form and vice versa. Most of our database tables are named in a plural fashion. When we go to create...
2
by: Robert W. | last post by:
In my current work I noticed that I have several circumstances where I need to create little if/else constructs to handle the phrasing of a message. This typically involves a ternary situation like...
4
by: John A Grandy | last post by:
could someone explain the following to me : Appending the literal type character I to a literal forces it to the Integer data type. Appending the identifier type character % to any identifier...
7
by: Bosconian | last post by:
This might seem like a trivial thing, but has anyone has come up with a better way of outputting a singular vs. plural string? For example: // default plural label $string = "appointments";...
0
by: Slypig | last post by:
Can anyone enlighten me on how to include plural searches with a fulltext mysql database search? For example, if someone searches 'restaurant' I want it to search the database for 'restaurant'...
31
by: Bill Norton | last post by:
Over at PCMag.com there is a debate going on over the usability of CSS. The discussion was initiated by an article by John Dvorak called "Why CSS Bugs Me"...
4
by: guate911 | last post by:
Does anyone know of an open source applictation or API I can connect to, that will allow me to find the plural of a word? For example, if I type in "mouse", I need it to find the plural.. "mice". ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.