Capitalization of Names from a Text Box Entry
Author |
Message |
Calum McLe #1 / 4
|
 Capitalization of Names from a Text Box Entry
Hopefully someone out there can help me, I'm new to VB, so this may sound like a very simple request (hopefully). I would like to be able to enter a name into a text box all in lower case format, such as 'john smith' and have it display this in correct syntax in a label, i.e. 'John Smith'. I've got as far as displaying the christain name properly, but I'm really stuck with the surname, I'm just not sure how to tell it start looking again after the space; any thoughts? I've copied my code below. ----------------------------------------------- Private Sub cmd_display_Click() Dim aString As String Dim Number As Integer Number = InStr(txt_enter_name.Text, " ") aString = Left(UCase(Left(txt_enter_name.Text, 1)) & LCase(Mid(txt_enter_name.Text, 2)), Number - 1) lbl_display.Caption = aString End Sub ----------------------------------------------- Oh, I know I could use: aString = StrConv(txt_enter_name, vbProperCase) but I'd like to work it out the other way first for future reference. Thanks,
|
Fri, 08 Apr 2005 03:49:23 GMT |
|
 |
Harry Strybo #2 / 4
|
 Capitalization of Names from a Text Box Entry
Quote: > Hopefully someone out there can help me, I'm new to VB, so this may > sound like a very simple request (hopefully). > I would like to be able to enter a name into a text box all in lower > case format, such as 'john smith' and have it display this in correct > syntax in a label, i.e. 'John Smith'. > I've got as far as displaying the christain name properly, but I'm > really stuck with the surname, I'm just not sure how to tell it start > looking again after the space; any thoughts? > I've copied my code below. > ----------------------------------------------- > Private Sub cmd_display_Click() > Dim aString As String > Dim Number As Integer > Number = InStr(txt_enter_name.Text, " ") > aString = Left(UCase(Left(txt_enter_name.Text, 1)) & > LCase(Mid(txt_enter_name.Text, 2)), Number - 1) > lbl_display.Caption = aString > End Sub > ----------------------------------------------- > Oh, I know I could use: > aString = StrConv(txt_enter_name, vbProperCase) > but I'd like to work it out the other way first for future reference. > Thanks,
Have a look at the StrConv function
|
Fri, 08 Apr 2005 04:00:58 GMT |
|
 |
Larry Linso #3 / 4
|
 Capitalization of Names from a Text Box Entry
Quote:
> I would like to be able to enter a
> name into a text box all in lower > case format, such as 'john smith' > and have it display this in correct > syntax in a label, i.e. 'John Smith'. In VB6, you can use the StrConv function with vbProperCase as the conversion. strString = StrConv(Me.Text1.Text, vbProperCase) but it'll also return each word capitalized for dirk van horn... Dirk Van Horn, instead of Dirk van Horn, and that is not always right. I think the StrConv function was in VB5, also, but I don't have VB5 available to check. Quote: > I've got as far as displaying the christain name properly, but
Really, even for Muslims, Hindus, Bhuddists, Shintos, Jews, etc.? -- Larry Linson http://www.ntpcug.org -- North Texas PC User Group http://members.tripod.com/ntaccess -- Access SIG http://members.tripod.com/accdevel -- Access Samples and Examples Quote: > I've copied my code below. > ----------------------------------------------- > Private Sub cmd_display_Click() > Dim aString As String > Dim Number As Integer > Number = InStr(txt_enter_name.Text, " ") > aString = Left(UCase(Left(txt_enter_name.Text, 1)) & > LCase(Mid(txt_enter_name.Text, 2)), Number - 1) > lbl_display.Caption = aString > End Sub > ----------------------------------------------- > Oh, I know I could use: > aString = StrConv(txt_enter_name, vbProperCase) > but I'd like to work it out the other way first for future reference. > Thanks,
|
Fri, 08 Apr 2005 06:02:56 GMT |
|
 |
the Wi #4 / 4
|
 Capitalization of Names from a Text Box Entry
Quote:
>Hopefully someone out there can help me, I'm new to VB, so this may >sound like a very simple request (hopefully). >I would like to be able to enter a name into a text box all in lower >case format, such as 'john smith' and have it display this in correct >syntax in a label, i.e. 'John Smith'.
Be aware that not all names are as easy as "John Smith". You will also need to properly handle "McAdams", "MacGill", McDale", "Macanally" and suffixes such as "Jr.", "Sr.", "II", "III", "IV". Some names require human intervention: how do you capitalize "deangelis"? The simple rule (valid maybe 80% of the time) is that the letter after "Mc" is capitalized. For the letter following "Mac", there is no rule :-( VB3 source code: http://thelabwiz.home.mindspring.com/vbsource.html VB6 source code: http://thelabwiz.home.mindspring.com/vb6source.html VB6 - MySQL how to: http://thelabwiz.home.mindspring.com/mysql.html Fix the obvious to reply by email.
|
Sat, 09 Apr 2005 09:48:03 GMT |
|
|
|