Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Changing letter casing

Changing letter casing

Scheduled Pinned Locked Moved Visual Basic
tutorialcsharphelpquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    justmeTW
    wrote on last edited by
    #1

    :(( I am using VB.NET and I have tried to find how to format a textbox to automatically change the first letter into a uppercase when someone types in the textbox. For example, I start typing in, food, when the first letter isnt capitalized I want it to automatically convert that first letter to uppercase, Food. Can anyone help? :confused: Tonnie

    C 1 Reply Last reply
    0
    • J justmeTW

      :(( I am using VB.NET and I have tried to find how to format a textbox to automatically change the first letter into a uppercase when someone types in the textbox. For example, I start typing in, food, when the first letter isnt capitalized I want it to automatically convert that first letter to uppercase, Food. Can anyone help? :confused: Tonnie

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      How about setting up a TextChanged event handler and doing a test, if the text starts with a lower case letter then change it. --Colin Mackay--

      "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)

      J 1 Reply Last reply
      0
      • C Colin Angus Mackay

        How about setting up a TextChanged event handler and doing a test, if the text starts with a lower case letter then change it. --Colin Mackay--

        "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)

        J Offline
        J Offline
        justmeTW
        wrote on last edited by
        #3

        My problem is how to test it, what code or codes do I use to test it, so it will automatically change the first char to an upper.

        C 1 Reply Last reply
        0
        • J justmeTW

          My problem is how to test it, what code or codes do I use to test it, so it will automatically change the first char to an upper.

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          I see a couple of ways. 1. Don't bother with a test and just do it this way:

          s = s.Substring(0,1).ToUpper() + s.Substring(1);

          You may need to test the length and conditionally omit the + s.Substring(1) 2. Get the first character, cast it to a number and test the range. You'll need to find an ASCII table, because I can't remember the codes. Option 1 may be better as the ToUpper() and ToLower() methods are culturally aware - If you have accented characters like áéíóú it will get them too, whereas with option 2 you need to find all possibilities yourself. --Colin Mackay--

          "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)

          J 1 Reply Last reply
          0
          • C Colin Angus Mackay

            I see a couple of ways. 1. Don't bother with a test and just do it this way:

            s = s.Substring(0,1).ToUpper() + s.Substring(1);

            You may need to test the length and conditionally omit the + s.Substring(1) 2. Get the first character, cast it to a number and test the range. You'll need to find an ASCII table, because I can't remember the codes. Option 1 may be better as the ToUpper() and ToLower() methods are culturally aware - If you have accented characters like áéíóú it will get them too, whereas with option 2 you need to find all possibilities yourself. --Colin Mackay--

            "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)

            J Offline
            J Offline
            justmeTW
            wrote on last edited by
            #5

            This is great, only one small problem, I dont know how to create substrings to work correctly, any ideas?

            C 1 Reply Last reply
            0
            • J justmeTW

              This is great, only one small problem, I dont know how to create substrings to work correctly, any ideas?

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              Emmmmm... I have no idea what you mean.... You have a string you call the substring method on it and Robert is your father's brother. --Colin Mackay--

              "In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups