?
Solved

MyText Project

Posted on 2012-03-24
2
Medium Priority
?
397 Views
Last Modified: 2012-03-24
I am getting this error. Can you help me with this issue?  Please be very specific with the discussion.  I am a student and in of need of information.  I have been given permission to get help with my projects from tutors.  

I must create a script that takes text that a user enters into a form field and converts it to title case capitalization.  Use a split()  method to split words in the string into an indexed array.  Then create a for loop that uses another split() method that splits each word in the elements of the indexed array into another another indexed array of characters.  Within the for loop, us he ToUpper() method to convert the first element in the second array (which represents the first characters in the word to uppercase) to uppercase, and then use the Join() method to rebuild the array of words in the text string.  Execute a final Join() method to convert the array of words back into a single text strin.  Save the project as TitleCase.
TitleCase.zip
error.docx
0
Comment
Question by:assaultkitty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 total points
ID: 37761063
A NullReferenceException means that an object you are trying to use is not initialized.

If you put the cursor over myText when you get the error, you will probably see that its value is null. This means that your request did not return any value. Your "stringOfWords" element is probably empty.

Whenever you are retrieving information and expect that it could be empty, you need to check for the condition before using the returned value:
string myText = Request.Form["stringOfWords"];
string[] myTextArray;

if ( !( myText == null ) )
     myTextArray = myText.Split ( ' ' );
else
     // Output a message or deal with the situation any way you see fit

Open in new window

Further on, no need to split the string into an array of characters. A .NET string is already an array or characters. You can access them individually as myTextArray[0][0], myTextArray[0][1]...myTextArray[1][0], myTextArray[1][1]...
I leave the rest to you... you need to work a little in order to learn :-)
0
 

Author Closing Comment

by:assaultkitty
ID: 37761335
string myText = Request.Form["stringOfWords"];
string[] myTextArray = myText.Split(' ');

This is the way that I did it.  Thanks for the hint.  I have problem with another issue. Thanks again.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question