By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,589 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

.text / String Manipulation

P: n/a
tma
I have a web form where users enter basic information such as their name and
address. How can I ensure that when that data gets written to the database
it gets "converted" to first letter capital, all others lower case? For
example "john doe" would go into the database as "John Doe". Is there an
easy way to do this?
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Thats called "Proper Case" Here's a little function for you.

'Any characters capitalized to begin with will remain so
'USA will still be USA
Function ProperCase(ByVal text As String) As String
Dim i As Integer
Dim mProperCase As String
' prepare the result
mProperCase = StrConv(text, vbProperCase)

' restore all those characters that were capitalized
For i = 1 To Len(text)
Select Case Asc(Mid$(text, i, 1))
Case 65 to 90 'A-Z
Mid$(mProperCase, i, 1) = Mid$(text, i, 1)
End Select
Next
Return mProperCase
End Function

Regards
Jerry

"tma" <tm*@allisconfusing.net> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
I have a web form where users enter basic information such as their name and address. How can I ensure that when that data gets written to the database
it gets "converted" to first letter capital, all others lower case? For
example "john doe" would go into the database as "John Doe". Is there an
easy way to do this?

Nov 20 '05 #2

P: n/a
tma
Thank you for the speedy reply. That's exactly what I was looking for.
"Jerry" <Je*********@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Thats called "Proper Case" Here's a little function for you.

'Any characters capitalized to begin with will remain so
'USA will still be USA
Function ProperCase(ByVal text As String) As String
Dim i As Integer
Dim mProperCase As String
' prepare the result
mProperCase = StrConv(text, vbProperCase)

' restore all those characters that were capitalized
For i = 1 To Len(text)
Select Case Asc(Mid$(text, i, 1))
Case 65 to 90 'A-Z
Mid$(mProperCase, i, 1) = Mid$(text, i, 1)
End Select
Next
Return mProperCase
End Function

Regards
Jerry

"tma" <tm*@allisconfusing.net> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
I have a web form where users enter basic information such as their name

and
address. How can I ensure that when that data gets written to the database it gets "converted" to first letter capital, all others lower case? For
example "john doe" would go into the database as "John Doe". Is there an
easy way to do this?


Nov 20 '05 #3

P: n/a
Here is one idea:

Public Shared Function ProperCase(ByVal input As String) As String
Return
System.Threading.Thread.CurrentThread.CurrentCultu re.TextInfo.ToTitleCase(in
put)
End Function

--
Joe Fallon


"tma" <tm*@allisconfusing.net> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
I have a web form where users enter basic information such as their name and address. How can I ensure that when that data gets written to the database
it gets "converted" to first letter capital, all others lower case? For
example "john doe" would go into the database as "John Doe". Is there an
easy way to do this?

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.