473,406 Members | 2,745 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,406 software developers and data experts.

Trying to convert to titlecase problem

I'm trying to take the value of a textbox and titleCase. A recent question
posted here by myself sent me to this page:

http://msdn2.microsoft.com/en-gb/lib...titlecase.aspx

Where I found this sample code:

Dim instance As TextInfo
Dim str As String
Dim returnValue As String

returnValue = instance.ToTitleCase(str)

Upon trying to use it on my page:

Dim str_title As String
Dim instance As System.Globalization.TextInfo
Dim str_titlePreCaseChange As String = Trim(tbx_title.Text)
str_title = instance.ToTitleCase(str_titlePreCaseChange)

I get an error on the last line of :
Object reference not set to an instance of an object.

....and I'm not sure why.

-Darrel
Dec 18 '06 #1
5 1513
Hi,
Incorrect One : Dim instance As System.Globalization.TextInfo
Correct One : Dim instance As System.Globalization.TextInfo = New
System.Globalization.TextInfo

Thanks and regards,
Manish Bafna.
MCP and MCTS.
"darrel" wrote:
I'm trying to take the value of a textbox and titleCase. A recent question
posted here by myself sent me to this page:

http://msdn2.microsoft.com/en-gb/lib...titlecase.aspx

Where I found this sample code:

Dim instance As TextInfo
Dim str As String
Dim returnValue As String

returnValue = instance.ToTitleCase(str)

Upon trying to use it on my page:

Dim str_title As String
Dim instance As System.Globalization.TextInfo
Dim str_titlePreCaseChange As String = Trim(tbx_title.Text)
str_title = instance.ToTitleCase(str_titlePreCaseChange)

I get an error on the last line of :
Object reference not set to an instance of an object.

....and I'm not sure why.

-Darrel
Dec 19 '06 #2
Try this...

System.Globalization.CultureInfo c = new
System.Globalization.CultureInfo("hi-IN");
System.Globalization.TextInfo d = c.TextInfo;
string title = d.ToTitleCase("ginesh kumar");

Manish Bafna wrote:
Hi,
Incorrect One : Dim instance As System.Globalization.TextInfo
Correct One : Dim instance As System.Globalization.TextInfo = New
System.Globalization.TextInfo

Thanks and regards,
Manish Bafna.
MCP and MCTS.
"darrel" wrote:
I'm trying to take the value of a textbox and titleCase. A recent question
posted here by myself sent me to this page:

http://msdn2.microsoft.com/en-gb/lib...titlecase.aspx

Where I found this sample code:

Dim instance As TextInfo
Dim str As String
Dim returnValue As String

returnValue = instance.ToTitleCase(str)

Upon trying to use it on my page:

Dim str_title As String
Dim instance As System.Globalization.TextInfo
Dim str_titlePreCaseChange As String = Trim(tbx_title.Text)
str_title = instance.ToTitleCase(str_titlePreCaseChange)

I get an error on the last line of :
Object reference not set to an instance of an object.

....and I'm not sure why.

-Darrel

Dec 19 '06 #3
Incorrect One : Dim instance As System.Globalization.TextInfo
Correct One : Dim instance As System.Globalization.TextInfo = New
System.Globalization.TextInfo
I'm using VB for this. The above example gives me a syntax error in VS: 'is
not accessible in this context because it is 'Private'

-Darrel

Dec 19 '06 #4
System.Globalization.CultureInfo c = new
System.Globalization.CultureInfo("hi-IN");
System.Globalization.TextInfo d = c.TextInfo;
string title = d.ToTitleCase("ginesh kumar");
Thanks, Manish.

What, exactly, is the CultureInfo part for?

-Darrel
Dec 19 '06 #5
Well, after some more googling, I found this:

str_title =
System.Threading.Thread.CurrentThread.CurrentCultu re.TextInfo.ToTitleCase(Trim(tbx_title.Text).ToLow er(System.Globalization.CultureInfo.InvariantCultu re))

And that seems to work. Wordy, but it works. ;o)

_Darrel
Dec 19 '06 #6

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

Similar topics

23
by: Hallvard B Furuseth | last post by:
Has someone got a Python routine or module which converts Unicode strings to lowercase (or uppercase)? What I actually need to do is to compare a number of strings in a case-insensitive manner,...
4
by: Garry Freemyer | last post by:
I'm trying to convert this macro to a c# function but I have a big problem. It's on the LEFT side of an assignment statement and I am extremely flustered over this one because I'm a little rusty...
7
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm...
2
by: Joebloggs | last post by:
Hi I am trying to do an ldap lookup. I can pick up the domain name in the standard format DOMAIN\USERNAME. The problem is the company I work for expects the query in the format DOMAIN:USERNAME....
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
5
by: Dennis | last post by:
I know this is probably a very overworked issue but thought I'd share the code below to convert words in a text string to capitalize the first letter of the word using an array of word delimiters. ...
2
by: lifeshortlivitup | last post by:
I am a java beginner and am trying to tackle a temperature conversion problem but I don't exactly know how to begin. The problem asks that I write a program that allows the user to conver either...
14
by: Paulo da Silva | last post by:
Hi! If I have two files .py such as m.py from c import * ... x=c() ... os.any_method ...
3
by: PGM | last post by:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Projname, ProjSpon As String Dim AppName, AppType, AppSupp, AppDesc As String...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.