Results 1 to 4 of 4

Thread: VB - Converts all initial letters to UCase.

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    VB - Converts all initial letters to UCase.

    This would converts all initial letters to upper case .For example this string "visual basic" turns into "Visual Basic"
    Attached Files Attached Files

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    This is a bit shorter and does the same:
    VB Code:
    1. Public Function UpAllWords(ByVal TEXTIN As String) As String
    2.     UpAllWords = StrConv(TEXTIN, vbProperCase)
    3. End Function

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Thumbs up

    Cool.

  4. #4
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    I am posting this here because it relates to converting all letters to uppercase. (Saves double posting)

    In this example if the character is a-z it converts it to uppercase.
    The line KeyAscii = Asc(UCase(Chr(KeyAscii))) will accept numbers without modifying them.
    Code:
    Private Sub text1_KeyPress(KeyAscii As Integer)
    MsgBox KeyAscii
    If KeyAscii >= 97 And KeyAscii <= 122 Then
        KeyAscii = Asc(UCase(Chr(KeyAscii)))
    Else
        KeyAscii = 0
    End If
    End Sub
    this works for any function that has the ascii value passed as a parameter.

    This code is part of a thread I started a while back, Hack came up with the solution. Credit goes to him.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width