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. Strings

Strings

Scheduled Pinned Locked Moved Visual Basic
helpquestion
4 Posts 4 Posters 1 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.
  • C Offline
    C Offline
    Cedrickdeorange
    wrote on last edited by
    #1

    I am using text boxes to enter names. If the text is entered in lower case letters i have put a line of code to change the first letter to upper case txtName1.Text = Char.ToUpper(txtName1.Text.Chars(0)).ToString() + txtName1.Text.Substring(1) like so. My problem is, suppose the name is double barreled like carly-anne i can change the C to a capital but how do i change the second name "anne" to "Anne" :confused: Thanks from Zeldacat

    M T 2 Replies Last reply
    0
    • C Cedrickdeorange

      I am using text boxes to enter names. If the text is entered in lower case letters i have put a line of code to change the first letter to upper case txtName1.Text = Char.ToUpper(txtName1.Text.Chars(0)).ToString() + txtName1.Text.Substring(1) like so. My problem is, suppose the name is double barreled like carly-anne i can change the C to a capital but how do i change the second name "anne" to "Anne" :confused: Thanks from Zeldacat

      M Offline
      M Offline
      mr_lasseter
      wrote on last edited by
      #2

      My guess would be to look at the previous letter and convert the current letter to Upper Case if it is a ' ' or a '-'.

      Mike Lasseter

      1 Reply Last reply
      0
      • C Cedrickdeorange

        I am using text boxes to enter names. If the text is entered in lower case letters i have put a line of code to change the first letter to upper case txtName1.Text = Char.ToUpper(txtName1.Text.Chars(0)).ToString() + txtName1.Text.Substring(1) like so. My problem is, suppose the name is double barreled like carly-anne i can change the C to a capital but how do i change the second name "anne" to "Anne" :confused: Thanks from Zeldacat

        T Offline
        T Offline
        Taylor
        wrote on last edited by
        #3
        This post is deleted!
        N 1 Reply Last reply
        0
        • T Taylor

          This post is deleted!

          N Offline
          N Offline
          Nouvand
          wrote on last edited by
          #4

          :)'Or you can try this. --------------with comments----------------- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Me.TextBox1.Text <> Nothing Then 'make sure the textbox value is exist. Dim NameParts As String() = Split(Me.TextBox1.Text) 'split the name parts into an array. Dim FullName As String = "" 'make a buffer to save the processed name parts. Dim nMax As Integer = NameParts.GetUpperBound(0) 'number of name parts. For i As Integer = 0 To nMax 'iterate through the element of name part array. 'Replace first character with upper case character on each elements. NameParts(i) = Mid(NameParts(i), 1, 1).ToUpper & Mid(NameParts(i), 2).ToLower FullName &= NameParts(i) & " " 'save into buffer. Next Dim xTrim As Integer = FullName.Length - 1 'count characther length in fullname FullName = Mid(FullName, 1, xTrim) 'remove space character at the end of fullname. Me.TextBox1.Text = FullName 'put the processed value back into textbox End If End Sub --------------without comments----------------- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Me.TextBox1.Text <> Nothing Then Dim NameParts As String() = Split(Me.TextBox1.Text) Dim FullName As String = "" Dim nMax As Integer = NameParts.GetUpperBound(0) For i As Integer = 0 To nMax NameParts(i) = Mid(NameParts(i), 1, 1).ToUpper & Mid(NameParts(i), 2).ToLower FullName &= NameParts(i) & " " Next Dim xTrim As Integer = FullName.Length - 1 FullName = Mid(FullName, 1, xTrim) Me.TextBox1.Text = FullName End If End Sub

          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