473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

.text / String Manipulation

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
3 1272
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Patrick | last post by:
Hello, after learning that I was taking a class in VB.NET, I have been drafted to solve all my companies VB/scripting problems - hey, I should know everything; I've already taken 6 classes ;) I...
1
by: Andrew Poulos | last post by:
Say I have a page, which has been created by a third party, and the page may contain some pre-specified text. How can I find and replace that text dynamically? For example, if the page I have...
5
by: ad | last post by:
I want to delete some text which begin with <!DOCTYPE and end with > in a file. How can I do it?
2
by: UJ | last post by:
I've got a text box that I'm going to be doing some manipulation on (selecting text, moving stuff around, that kind of thing) but I don't want/need the user to see it while it's going on. I'd like...
4
by: WaterWalk | last post by:
Hello, I'm currently learning string manipulation. I'm curious about what is the favored way for string manipulation in C, expecially when strings contain non-ASCII characters. For example, if...
3
by: Alois Treindl | last post by:
A simple XSL question from a newbie: In an xml document which I transform via xsl into html output, I have some text which I want to be suppressed. The tags looks like this <anchor_ref...
6
by: garyusenet | last post by:
Hi i would like to trim a text string. I have a text string called filename I want to display just the file in my label, and not the path. Can someone tell me how I get everything AFTER, the...
0
by: JosAH | last post by:
Greetings, welcome back; above we discussed the peripherals of the Library class: loading and saving such an instantiation of it, the BookMark interface and then some. This part of the article...
1
by: blangela | last post by:
Bjarne Stroustrup has a new text coming out called "Programming: Principles and Practice Using C++" (ISBN: 0321543726), due to be published in December of this year. Some of the features of this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.