473,394 Members | 1,737 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,394 software developers and data experts.

Is there a function that will Capitalize words in a string?

Hi all. Checked the docs and all I can find is UCase but that will convert
everything to upper. What I want is when my users enter say a name into a
text box I want to just upper the first char for them if they forget to.

TIA

Robert
Jun 25 '07 #1
7 8390
Robert,

VB's StrConv function will do that. For example:

StudentName = StrConv(StudentName , VbStrConv.ProperCase)

I don't know of a ".Net" way of accomplishing the same thing.

Kerry Moorman
"Robert Johnson" wrote:
Hi all. Checked the docs and all I can find is UCase but that will convert
everything to upper. What I want is when my users enter say a name into a
text box I want to just upper the first char for them if they forget to.

TIA

Robert
Jun 25 '07 #2
Kerry Moorman wrote:
Robert,

VB's StrConv function will do that. For example:

StudentName = StrConv(StudentName , VbStrConv.ProperCase)

I don't know of a ".Net" way of accomplishing the same thing.
For ProperCase, the ".NET" way is exactly the same as VB6, no difference.

The following is from VB2005 Help -

Visual Basic 6.0 Visual Basic 2005 Equivalent
vbUpperCase VbStrConv.UpperCase

vbLowerCase VbStrConv.LowerCase

vbProperCase VbStrConv.ProperCase

vbWide VbStrConv.Wide

vbNarrow VbStrConv.Narrow

vbKatakana VbStrConv.Katakana

vbHiragana VbStrConv.Hiragana

vbUnicode No equivalent constant. You can achieve the same functionality
by using the Convert method.

vbFromUnicode No equivalent

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Jun 25 '07 #3

"Robert Johnson" <jo*******@sbcglobal.netwrote in message
news:eB**************@TK2MSFTNGP03.phx.gbl...
Hi all. Checked the docs and all I can find is UCase but that will convert
everything to upper. What I want is when my users enter say a name into a
text box I want to just upper the first char for them if they forget to.
Dim x As String = Textbox1.Text.Substring(1).ToUpper

You can play it anyway you want with a function of your own making or
whatever to return the string with the first character in upper case.

Function 1stCharUpper(ctrl as Textbox)

do what you have to do in the manipulation of the string.

dim x as string = ctrl.Text.Substring(1).ToUpper

return x = x & ctrl.text.substring(2, length)

end function

Jun 25 '07 #4
Thank you Kerry

Robert
"Kerry Moorman" <Ke**********@discussions.microsoft.comwrote in message
news:B8**********************************@microsof t.com...
Robert,

VB's StrConv function will do that. For example:

StudentName = StrConv(StudentName , VbStrConv.ProperCase)

I don't know of a ".Net" way of accomplishing the same thing.

Kerry Moorman
"Robert Johnson" wrote:
>Hi all. Checked the docs and all I can find is UCase but that will
convert
everything to upper. What I want is when my users enter say a name into a
text box I want to just upper the first char for them if they forget to.

TIA

Robert

Jun 26 '07 #5
Thank you ShaneO

Robert
"ShaneO" <sp****@optusnet.com.auwrote in message
news:46***********************@news.optusnet.com.a u...
Kerry Moorman wrote:
>Robert,

VB's StrConv function will do that. For example:

StudentName = StrConv(StudentName , VbStrConv.ProperCase)

I don't know of a ".Net" way of accomplishing the same thing.

For ProperCase, the ".NET" way is exactly the same as VB6, no difference.

The following is from VB2005 Help -

Visual Basic 6.0 Visual Basic 2005 Equivalent
vbUpperCase VbStrConv.UpperCase

vbLowerCase VbStrConv.LowerCase

vbProperCase VbStrConv.ProperCase

vbWide VbStrConv.Wide

vbNarrow VbStrConv.Narrow

vbKatakana VbStrConv.Katakana

vbHiragana VbStrConv.Hiragana

vbUnicode No equivalent constant. You can achieve the same functionality
by using the Convert method.

vbFromUnicode No equivalent

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.

Jun 26 '07 #6
Thank you M. Arnold

Robert
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:uj**************@TK2MSFTNGP04.phx.gbl...
>
"Robert Johnson" <jo*******@sbcglobal.netwrote in message
news:eB**************@TK2MSFTNGP03.phx.gbl...
>Hi all. Checked the docs and all I can find is UCase but that will
convert everything to upper. What I want is when my users enter say a
name into a text box I want to just upper the first char for them if they
forget to.

Dim x As String = Textbox1.Text.Substring(1).ToUpper

You can play it anyway you want with a function of your own making or
whatever to return the string with the first character in upper case.

Function 1stCharUpper(ctrl as Textbox)

do what you have to do in the manipulation of the string.

dim x as string = ctrl.Text.Substring(1).ToUpper

return x = x & ctrl.text.substring(2, length)

end function

Jun 26 '07 #7
Kerry,

Probably you mean with the .Net way. A way in the .Net namespace System.Net,
there is not, this is in the .Net namespace VisualBasic.

Cor

"Kerry Moorman" <Ke**********@discussions.microsoft.comschreef in bericht
news:B8**********************************@microsof t.com...
Robert,

VB's StrConv function will do that. For example:

StudentName = StrConv(StudentName , VbStrConv.ProperCase)

I don't know of a ".Net" way of accomplishing the same thing.

Kerry Moorman
"Robert Johnson" wrote:
>Hi all. Checked the docs and all I can find is UCase but that will
convert
everything to upper. What I want is when my users enter say a name into a
text box I want to just upper the first char for them if they forget to.

TIA

Robert

Jun 26 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Rick | last post by:
For some reason my function to capitalize the first letter in a string and keep all the other letters lowercase isn't working. This is what I have. string convname(string name) { int len;...
4
by: MLH | last post by:
The following function declaration confuses me... Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean I tried pasting it and its code into an...
2
by: Yuan Zhong | last post by:
hello all, not sure if it's appropriate to post here. If not, I am sorry and please direct me to the right groups. Thanks. I write this function to permute a string. e.g. if the input string is...
1
by: The_Kingpin | last post by:
Hi all, I need to make a function that convert a string into a certain format. Here what are the restriction: -The first letter of the first and last name must be uppercase. -If a first name...
7
by: Li Pang | last post by:
Hi, I'd like to know how to call a sub/function bu using a string containing its name, as an example as follow: Sub Main() Dim name As String = "TestMe()" ' need help here End Sub
3
by: ashok | last post by:
Hi, I need a function that will divide text from mysql in 2 parts, so that I can display first half in one column and second half in second column. I can't find what function will do this job....
6
by: Xernoth | last post by:
Hi, I have an exercise that requests the following: Write a function that reads words from an input stream and stores them in a vector. Use that function both to write programs that count the...
11
by: dolphin | last post by:
Hi All! I have a question that how to call a function just using a string. For example There is a .cpp file named a.cpp.There are some functions::fun1() fun2() fun3(). I have another fucntion...
0
by: John | last post by:
Hi I have written a function to split a string into sub strings of a given fixed max length. This is useful for example in breaking a long message into multiple strings of up to 160 characters...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.