Jump to content

Testar funcao da 1ª letra maiuscula


esquima

Recommended Posts

alguem pode testar esta função e tentar me ajudar como e que faço uma alteraçao nela

o problema e que ela mete a 1ªletra maiscula, so que se eu quiser alterar algumas letras no meio de uma palavar ela so me altera 1 e mete logo o cursor no fim da palavra..

vou deixar aqui o codigo..fica dentro do evento textchanged de uma text box

'mete a primeira letra maiuscula na 1ª palavra
        Dim txb As New TextBox
        txb = sender

        If Not String.IsNullOrEmpty(txb.Text.Trim) Then
            Dim s As String = ""
            s = Char.ToUpper(txb.Text.Chars(0))
            txb.Text = s + txb.Text.Substring(1)
            txb.Select(txb.TextLength, 1)
        End If


Link to comment
Share on other sites

Vê se serve (só acrescentei "ToString" e modifiquei o cabeçalho do "If..End if") :

'mete a primeira letra maiuscula na 1ª palavra     
        Dim txb As New TextBox
        txb = sender
        If txb.Text <> "" Then


            Dim s As String = ""
            s = Char.ToUpper(txb.Text.Chars(0))
            txb.Text = s + txb.Text.Substring(1).ToString
            txb.Select(txb.TextLength, 1)

        End If
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.