Jul 29th, 2003, 11:43 AM
#1
Thread Starter
Addicted Member
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 .
Jul 29th, 2003, 12:13 PM
#2
How about
VB Code:
Text1.Text = StrConv(Text1.Text, vbProperCase)
Jul 29th, 2003, 01:30 PM
#3
So Unbanned
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:
i = instr(mystr," ")
'find first occurance of a space in the string also InstrRev(starts from end)
'loops while there is an occurance
While i
'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
mystr = left$(mystr,i) & ucase(mid$(mystr,i+1,1)) & mid$(mystr, i+2)
'increment i to find the next occurance, if not found loop ends
i = instr(i+1,mystr," ")
Wend
Jul 29th, 2003, 01:38 PM
#4
Thread Starter
Addicted Member
DiGiTaIErRoR and kleinma
Anyone of you donwloaded the zip? and see the vb project
Jul 29th, 2003, 03:36 PM
#5
Frenzied Member
Please excuse me for being white, but, what zip?
Jul 29th, 2003, 09:39 PM
#6
Thread Starter
Addicted Member
Attached Files
Jul 29th, 2003, 09:49 PM
#7
The picture isn't missing
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Len(Text1.Text) = 0 Then
KeyAscii = Asc(UCase(Chr(KeyAscii)))
ElseIf Mid(Text1.Text, Text1.SelStart, 1) = " " Then
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
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
Forum Rules
Click Here to Expand Forum to Full Width