Results 1 to 5 of 5

Thread: help with Foematting uppercase

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    43

    help with Foematting uppercase

    I use this - sInput2 = UCase(Mid(sInput2, 1, 1)) + LCase(Mid(sInput2, 2)) to force upercase on first two characters of text in customer number eg db1234 to go DB1234

    Does any one know how to force input like new york to force the N and Y to uppercase. N is ease but I can't managed the one after a space. Also how to force after a .

    Lots of people not inputing data corectly

    Much apreciated

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: help with Foematting uppercase

    Quote Originally Posted by RayComp
    I use this - sInput2 = UCase(Mid(sInput2, 1, 1)) + LCase(Mid(sInput2, 2)) to force upercase on first two characters of text in customer number eg db1234 to go DB1234
    If you need first TWO chars in upper case then use the following:

    sInput2 = UCase(Mid("db1234", 1, 2)) + LCase(Mid("db1234", 3))


    Quote Originally Posted by RayComp
    ...Does any one know how to force input like new york to force the N and Y to uppercase...
    VB Code:
    1. Debug.Print StrConv("new york", vbProperCase) 'this will result in "New York"

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    43

    Re: help with Foematting uppercase

    Thanks. Trouble is that the input can be any city and is stored in access database.

    So input is random and need to force the input to display capital letter after the space.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: help with Foematting uppercase

    Quote Originally Posted by RayComp
    Thanks. Trouble is that the input can be any city and is stored in access database.

    So input is random and need to force the input to display capital letter after the space.
    All you need to do is to substitute the variable name that contains your state name in Rhino's code, like

    Debug.Print StrConv(MyStateName, vbProperCase)

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: help with Foematting uppercase

    Quote Originally Posted by RayComp
    Thanks. Trouble is that the input can be any city and is stored in access database.

    So input is random and need to force the input to display capital letter after the space.
    That's no trouble... As Martin stated just replace hard coded "new york" (which was done only for demonstration as most of our samples) with some variable you might have.
    Or you may even wrapp it in a function:
    VB Code:
    1. Public Function ConvertToProperCase(ByVal strValue As String) As String
    2.     ConvertToProperCase = StrConv(strValue, vbProperCase)
    3. End Function
    4.  
    5. 'usage:
    6. Private Sub Command1_Click()
    7. Dim sOldValue$, sNewValue$
    8.  
    9.     sOldValue = "new york"
    10.     sNewValue = ConvertToProperCase(sOldValue)
    11.     Debug.Print sNewValue
    12.  
    13. End Function

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