Function to evaluate whether a string is all UPPER

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

    Function to evaluate whether a string is all UPPER

    I'm trying to clean up strings in a web form before I plug the fields
    into a database. Lots of folks like to leave caps lock key on and
    yell their form entries.

    I can figure out how to change strings to sentence case, but I don't
    want to do it to every string since some correctly entered words e.g.
    "to" would be converted unnecessarily (to "To"). I'm willing to live
    with the over correction on a few strings, but don't want to apply it
    to the entire database.

    Has anyone used a function to evaluate whether a string has been
    entered all in upper case?


    Thanks,

    Brad Smith
    pbs at myrealboxNOSPAM .com
    remove NOSPAM from address and replace at with @ to email me directly
  • Kevin Spencer

    #2
    Re: Function to evaluate whether a string is all UPPER

    Convert the string to all upper case, and compare the result to the original
    string. If they are equal, the original string is all upper case.

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer

    Big things are made up of
    lots of Little things.

    "Brad Smith" <pbs@mailandnew s.com> wrote in message
    news:65529f27.0 306270727.2bea8 9c3@posting.goo gle.com...[color=blue]
    > I'm trying to clean up strings in a web form before I plug the fields
    > into a database. Lots of folks like to leave caps lock key on and
    > yell their form entries.
    >
    > I can figure out how to change strings to sentence case, but I don't
    > want to do it to every string since some correctly entered words e.g.
    > "to" would be converted unnecessarily (to "To"). I'm willing to live
    > with the over correction on a few strings, but don't want to apply it
    > to the entire database.
    >
    > Has anyone used a function to evaluate whether a string has been
    > entered all in upper case?
    >
    >
    > Thanks,
    >
    > Brad Smith
    > pbs at myrealboxNOSPAM .com
    > remove NOSPAM from address and replace at with @ to email me directly[/color]


    Comment

    • Blaise Pascal Tine

      #3
      RE: Function to evaluate whether a string is all UPPER

      Hi Brad,

      Could you try this:

      string a = "Dodo";
      if (a == a.ToUpper())
      {
      // the string is all in uppercase!
      }

      Thanks,
      Blaise Pascal Tine (MSFT).
      --------------------[color=blue]
      >From: pbs@mailandnews .com (Brad Smith)
      >Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
      >Subject: Function to evaluate whether a string is all UPPER
      >Date: 27 Jun 2003 08:27:00 -0700
      >Organization : http://groups.google.com/
      >Lines: 19
      >Message-ID: <65529f27.03062 70727.2bea89c3@ posting.google. com>
      >NNTP-Posting-Host: 129.111.166.176
      >Content-Type: text/plain; charset=ISO-8859-1
      >Content-Transfer-Encoding: 8bit
      >X-Trace: posting.google. com 1056727621 21410 127.0.0.1 (27 Jun 2003[/color]
      15:27:01 GMT)[color=blue]
      >X-Complaints-To: groups-abuse@google.co m
      >NNTP-Posting-Date: 27 Jun 2003 15:27:01 GMT
      >Path:[/color]
      cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
      e.de!news-spur1.maxwell.s yr.edu!news.max well.syr.edu!sn-xit-03!sn-xit-01!sn-
      xit-09!supernews.co m!postnews1.goo gle.com!not-for-mail[color=blue]
      >Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1554 60
      >X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
      >
      >I'm trying to clean up strings in a web form before I plug the fields
      >into a database. Lots of folks like to leave caps lock key on and
      >yell their form entries.
      >
      >I can figure out how to change strings to sentence case, but I don't
      >want to do it to every string since some correctly entered words e.g.
      >"to" would be converted unnecessarily (to "To"). I'm willing to live
      >with the over correction on a few strings, but don't want to apply it
      >to the entire database.
      >
      >Has anyone used a function to evaluate whether a string has been
      >entered all in upper case?
      >
      >
      >Thanks,
      >
      >Brad Smith
      >pbs at myrealboxNOSPAM .com
      >remove NOSPAM from address and replace at with @ to email me directly
      >[/color]

      Comment

      Working...