.text / String Manipulation

  • Thread starter Thread starter tma
  • Start date Start date
T

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?
 
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
 
Here is one idea:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top