Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I want a code that make all first letters in every words in the sentence : capital and the rest of letters small. and i need them to be printed in listbox.
by using for example :
for
if
chars
toupper
and any other funiction that may help .
 

thans for help..
Posted 13-Dec-12 2:41am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I have used this helper method for a while to do this:
public static string ToTitleCaseString(object value)
{
   if (value == null || value.ToString().Length == 0) { return string.Empty; }
   string s = System.Convert.ToString(value, CultureInfo.InvariantCulture);
   return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(s.ToLower());
}
  Permalink  
Comments
aspnet_regiis -i at 13-Dec-12 9:57am
   
+5.. Bookmarked
Marcus Kramer at 13-Dec-12 10:30am
   
Thanks.
__TR__ at 14-Dec-12 13:36pm
   
My 5!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
Ex)
string str="hello";
 
str=str.substring(0,1).toUpper()+str.substring(1).tolower();
  Permalink  
Comments
Marcus Kramer at 13-Dec-12 10:31am
   
Will work if there is only 1 word in the argument, but what about if there are multiple words, ie. "my title". The result in your case would be "My title" instead of "My Title".
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I got the answer
 
        Dim s As String = "tariq naji ahmed";
        Dim a As String = 0
        For i As Byte = 0 To s.Length - 1
            If s.Chars(i) = s.Chars(0) Then
 
                a = s.ToUpper().Chars(i)
 
            ElseIf s.Chars(i) = " " Then
                a = a & s.Chars(i)
                i += 1
                a = a & s.ToUpper().Chars(i)
 
            Else
                a = a & s.Chars(i)
            End If
        Next
        TextBox1.Text = a
 
    End Sub
[Edit]Code block added[/Edit]
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 434
1 Nirav Prabtani 338
2 Abhinav S 170
3 PIEBALDconsult 160
4 Dave Kreskowiak 155
0 OriginalGriff 7,640
1 Sergey Alexandrovich Kryukov 6,836
2 Maciej Los 3,919
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100