andy_dyer
Registered User.
- Local time
- Today, 16:26
- Joined
- Jul 2, 2003
- Messages
- 806
Hi
I'm using this code that I found on the internet to correct capitilisation
My problem is that i have two areas this doesn't help
1) For degree titles i.e. PhD and MSc
2) For my company we have a set of "initials" to refer to eachother as these can range from two to five characters which should all be capitalised but without "." between the letters - if I need to I am happy to put anything round these characters to distinguish them i.e. [ ]
So for example we could have the sitiation where I want a project title to be
PhD Project - [ABCDE] (Blah Blah Blah Blah)
And with the code above I get
Phd Project - Abcde (Blah Blah Blah Blah)
Can anyone who can actually make any sense of the code above suggest some new "Cases" and their associated code that I can use?
Many thanks
I'm using this code that I found on the internet to correct capitilisation
Code:
Public Function ProperCase(AnyText As Variant) As String
'r_cubed
'Convert passed text to all lowercase. Use ProperCase() as you would a built-in Access function.
'If passed value is a null, ignore all the stuff below.
If IsNull(Nz(AnyText, Null)) Then GoTo Exit_ProperCase
Dim intCounter As Integer, OneChar As String
'First convert to initial cap, followed by all lowercase.
AnyText = UCase$(Left$(AnyText, 1)) & LCase$(Mid$(AnyText, 2))
'Look at each character, starting at the second character.
For intCounter = 2 To Len(AnyText)
OneChar = Mid$(AnyText, intCounter, 1)
'If current character (OneChar) is a space or hyphen...
Select Case OneChar
Case "-", "/", ".", "'", "&", "(", " "
'...convert the character after space/hyphen/slash/period/apostrophe/ampersand to uppercase.
' Such as A.B.C. Industries, Sharron O'Conner, B&B Mfg
AnyText = Left$(AnyText, intCounter) & UCase$(Mid$(AnyText, intCounter + 1, 1)) & Mid$(AnyText, intCounter + 2, 255)
Case "c"
' Take care of the McAfee's, McDonalds, McLaughlins
If Mid$(AnyText, intCounter - 1, 1) = "M" Then
AnyText = Left$(AnyText, intCounter) & UCase$(Mid$(AnyText, intCounter + 1, 1)) & Mid$(AnyText, intCounter + 2, 255)
Else
' Handle the MacDonalds, MacPherson and such
If (intCounter > 2 _
And Mid$(AnyText, intCounter - 2, 2) = "Ma") Then
AnyText = Left$(AnyText, intCounter) & UCase$(Mid$(AnyText, intCounter + 1, 1)) & Mid$(AnyText, intCounter + 2, 255)
End If
End If
Case " "
Select Case Mid$(AnyText, intCounter + 1, 2)
Case "de"
'Add any other exceptions here Example: Oscar de La Hoya
AnyText = Left$(AnyText, intCounter) & LCase$(Mid$(AnyText, intCounter + 1, 1)) & Mid$(AnyText, intCounter + 2, 255)
Case Else
' Example: A B C Manufacturing
AnyText = Left$(AnyText, intCounter) & UCase$(Mid$(AnyText, intCounter + 1, 1)) & Mid$(AnyText, intCounter + 2, 255)
End Select
End Select
Next
'All done, return current contents of AnyText variable.
ProperCase = AnyText
Exit_ProperCase:
End Function
My problem is that i have two areas this doesn't help
1) For degree titles i.e. PhD and MSc
2) For my company we have a set of "initials" to refer to eachother as these can range from two to five characters which should all be capitalised but without "." between the letters - if I need to I am happy to put anything round these characters to distinguish them i.e. [ ]
So for example we could have the sitiation where I want a project title to be
PhD Project - [ABCDE] (Blah Blah Blah Blah)
And with the code above I get
Phd Project - Abcde (Blah Blah Blah Blah)
Can anyone who can actually make any sense of the code above suggest some new "Cases" and their associated code that I can use?
Many thanks