String.ToUpper

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

    #1

    String.ToUpper

    Hi,

    I have a string 'hello world'

    I can UCase my string using String.ToUpper

    Is there anyway to just UCase the first letter ofe ach
    word?

    Thanks,
    Keeri.
  • news.microsoft.com

    #2
    Re: String.ToUpper

    override ToUpper.

    "Kerri" <anonymous@disc ussions.microso ft.com> wrote in message
    news:011901c39b f6$f07b7a30$a40 1280a@phx.gbl.. .[color=blue]
    > Hi,
    >
    > I have a string 'hello world'
    >
    > I can UCase my string using String.ToUpper
    >
    > Is there anyway to just UCase the first letter ofe ach
    > word?
    >
    > Thanks,
    > Keeri.[/color]


    Comment

    • Nicole Calinoiu

      #3
      Re: String.ToUpper

      Kerri,

      The String object does not contain a method for converting a string to
      title/proper case. You can, however, use the ToTitleCase method of the
      TextInfo object. See the following links for details:


      http://msdn.microsoft.com/library/en...eCaseTopic.asp

      HTH,
      Nicole


      "Kerri" <anonymous@disc ussions.microso ft.com> wrote in message
      news:011901c39b f6$f07b7a30$a40 1280a@phx.gbl.. .[color=blue]
      > Hi,
      >
      > I have a string 'hello world'
      >
      > I can UCase my string using String.ToUpper
      >
      > Is there anyway to just UCase the first letter ofe ach
      > word?
      >
      > Thanks,
      > Keeri.[/color]


      Comment

      • Peter Rilling

        #4
        Re: String.ToUpper

        How can you override ToUpper()? The class is sealed.

        "news.microsoft .com" <anonymouse@dis cussions.micros oft.com> wrote in message
        news:O3cU%23f$m DHA.3256@tk2msf tngp13.phx.gbl. ..[color=blue]
        > override ToUpper.
        >
        > "Kerri" <anonymous@disc ussions.microso ft.com> wrote in message
        > news:011901c39b f6$f07b7a30$a40 1280a@phx.gbl.. .[color=green]
        > > Hi,
        > >
        > > I have a string 'hello world'
        > >
        > > I can UCase my string using String.ToUpper
        > >
        > > Is there anyway to just UCase the first letter ofe ach
        > > word?
        > >
        > > Thanks,
        > > Keeri.[/color]
        >
        >[/color]


        Comment

        • news.microsoft.com

          #5
          Re: String.ToUpper

          Hammer, chissel, size 9 shoe.


          Roll yer own then. Not that hard.

          "Peter Rilling" <peter@nospam.r illing.net> wrote in message
          news:OYKvX6$mDH A.2064@TK2MSFTN GP11.phx.gbl...[color=blue]
          > How can you override ToUpper()? The class is sealed.
          >
          > "news.microsoft .com" <anonymouse@dis cussions.micros oft.com> wrote in[/color]
          message[color=blue]
          > news:O3cU%23f$m DHA.3256@tk2msf tngp13.phx.gbl. ..[color=green]
          > > override ToUpper.
          > >
          > > "Kerri" <anonymous@disc ussions.microso ft.com> wrote in message
          > > news:011901c39b f6$f07b7a30$a40 1280a@phx.gbl.. .[color=darkred]
          > > > Hi,
          > > >
          > > > I have a string 'hello world'
          > > >
          > > > I can UCase my string using String.ToUpper
          > > >
          > > > Is there anyway to just UCase the first letter ofe ach
          > > > word?
          > > >
          > > > Thanks,
          > > > Keeri.[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • David Sworder

            #6
            Re: String.ToUpper

            > I can UCase my string using String.ToUpper[color=blue]
            >
            > Is there anyway to just UCase the first letter ofe ach
            > word?
            >
            > Thanks,
            > Keeri.[/color]

            Uh-oh, you spelled your name wrong. How about something like this:



            David


            Comment

            • Mr. B

              #7
              Re: String.ToUpper

              With Deft Fingers, "Kerri" <anonymous@disc ussions.microso ft.com> wrote:
              [color=blue]
              >I have a string 'hello world'
              >I can UCase my string using String.ToUpper
              >
              >Is there anyway to just UCase the first letter ofe ach
              >word?[/color]

              Use ----> VbStrConv.Prope rCase

              Dim strName As String = txbModUser.Text
              strName = StrConv(strName , VbStrConv.Prope rCase)
              txbModUser.Text = strName

              Regards,

              Bruce

              Comment

              • IbrahimMalluf

                #8
                Re: String.ToUpper

                Hmmm....the ToTitleCase method of the TextInfo object works like someone
                else suggested here.

                Or you could use regular expressions with a delegate function as in the code
                below. I think the TotitleCase method would be much faster for iterative
                operations...ma ybe :-)

                Ibrahim Malluf


                Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
                System.EventArg s) Handles Button2.Click

                Dim MyReg As New System.Text.Reg ularExpressions .Regex("\b\w*\b ",
                System.Text.Reg ularExpressions .RegexOptions.I gnoreCase)

                Me.TextBox1.Tex t = MyReg.Replace(M e.TextBox1.Text , AddressOf Capitalize)

                End Sub

                Private Function Capitalize(ByVa l m As System.Text.Reg ularExpressions .Match)
                As String

                If m.Value.Length > 1 Then

                Capitalize = m.Value.Substri ng(0, 1).ToUpper & m.Value.Substri ng(1)

                Else

                Capitalize = m.Value.ToUpper

                End If

                End Function


                "Kerri" <anonymous@disc ussions.microso ft.com> wrote in message
                news:011901c39b f6$f07b7a30$a40 1280a@phx.gbl.. .[color=blue]
                > Hi,
                >
                > I have a string 'hello world'
                >
                > I can UCase my string using String.ToUpper
                >
                > Is there anyway to just UCase the first letter ofe ach
                > word?
                >
                > Thanks,
                > Keeri.[/color]


                Comment

                Working...