**hey guys ,
i was wondering how to take the first letter of the user's input and turn it into upper case then put it in another text block !!
for example i got 3 textboxes the first one user enters "hey" and in the second he enters "lol" and in the third he enters "bye"
how to get the word "hlb" in another text box in uppercase letter please :D its urgent **

Hi abdlrahman.etry welcome here at DaniWeb.
Please read the rules.
Browsing through this might give you some ideas.
What have you done for yourself already?
Don't be afraid to show us code that doesn't work.

I would add an extra button. In the click event handler of that button. I would construct my new string, using the Text property of the first 3 textboxes and the methods SubString and ToUpper of the string class. Now only thing needed is Txb4.Text = MyNewString;

You can always convert the word entered by the user into to a char array and take the charactor in the first index

Something like:

Char[] charactorArray1 = textBox1.ToCharArray();
string newString = charactorArray[0].ToString();

Char[] charactorArray2 = textBox2.ToCharArray();
string newString = newString + charactorArray2[0].ToString();

Char[] charactorArray3 = textBox3.ToCharArray();
string newString = newString + charactorArray3[0].ToString();

If you had more than 3 text boxes for the user to input into it would be best to do the above in a loop.

Edited 2 Years Ago by ChrisHunter

Your question did not specify whether Windows Forms, WPF or AspNet. I'll assume a windows application and not an Asp.Net application. If I understand your question correctly the following code should do the trick:

The text changed event handler on your text box invokes a function to build the first letter string whenever the text in the text boxes change. I substitued a blank space when a text box is empty to keep position.

private string firstLetter(string text)
{
    return string.IsNullOrEmpty(text) ? " " : text.Substring(0,1).ToUpper(); 
}

private void updateFirstLetters()
{
    if (tbFirstLetters != null)
    {
        tbFirstLetters.Text = firstLetter(tb1.Text) + firstLetter(tb2.Text) + firstLetter(tb3.Text);
    }
}

private void tb1_TextChanged(object sender, TextChangedEventArgs e)
{
    updateFirstLetters();
}

private void tb2_TextChanged(object sender, TextChangedEventArgs e)
{
    updateFirstLetters();
}

private void tb3_TextChanged(object sender, TextChangedEventArgs e)
{
    updateFirstLetters();
}

Edited 2 Years Ago by PoorRogue: Added ToUpper()

This article has been dead for over six months. Start a new discussion instead.