Results 1 to 7 of 7

Thread: First char after a blank space in Uppercase? [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member Sanko's Avatar
    Join Date
    Mar 2000
    Location
    Argentina
    Posts
    128

    Exclamation First char after a blank space in Uppercase? [RESOLVED]

    Hi again.
    I making a project for school

    in a textbox i must enter a name and it show the first character after a blank space in Uppercase

    if i enter mike jordan the textbox must show Mike Jordan

    I do a function but i have problems using the Backspace and Delete keys. The teacher want to do this with the keypress event, so i do this function but with my programing skill i cant do more. I hope you can help me.

    This is the function maybe it can be optimized for a better code and i put the vb project.
    Last edited by Sanko; Jul 29th, 2003 at 02:56 PM.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    How about
    VB Code:
    1. Text1.Text = StrConv(Text1.Text, vbProperCase)

  3. #3
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Yea...

    I was gonna say...

    That's an awful lot of code.

    But simply for educational purposes I'll show you a good way of pattern searching.

    VB Code:
    1. i = instr(mystr," ")
    2. 'find first occurance of a space in the string also InstrRev(starts from end)
    3. 'loops while there is an occurance
    4. While i
    5.  'grabs the left part of the string upto the space, then grabs the letter after the space Ucase's it then adds the remaining string
    6.  mystr = left$(mystr,i) & ucase(mid$(mystr,i+1,1)) & mid$(mystr, i+2)
    7. 'increment i to find the next occurance, if not found loop ends
    8. i = instr(i+1,mystr," ")
    9. Wend

  4. #4

    Thread Starter
    Addicted Member Sanko's Avatar
    Join Date
    Mar 2000
    Location
    Argentina
    Posts
    128

    Angry

    DiGiTaIErRoR and kleinma

    Anyone of you donwloaded the zip? and see the vb project

  5. #5
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    Please excuse me for being white, but, what zip?

  6. #6

    Thread Starter
    Addicted Member Sanko's Avatar
    Join Date
    Mar 2000
    Location
    Argentina
    Posts
    128
    Here is the zip
    Attached Files Attached Files

  7. #7
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.     If Len(Text1.Text) = 0 Then
    3.         KeyAscii = Asc(UCase(Chr(KeyAscii)))
    4.     ElseIf Mid(Text1.Text, Text1.SelStart, 1) = " " Then
    5.         KeyAscii = Asc(UCase(Chr(KeyAscii)))
    6.     End If
    7. End Sub
    Remember, if someone's post was not helpful, you can always rate their post negatively .

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