Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I just wanna ask something.


How to put commas in each letter of any word that i want? and how to execute that code while im currently typing the data in the textbox? and dont include the comma in the first letter that i will put please help me because i tyr all


Any code will be a great help for me and the future thank you
Posted
Comments
ShivKrSingh 28-Jul-13 6:23am    
you can track space for doing this. when system find space and replace that space with (,) comma.
Crixalis Paul 28-Jul-13 6:27am    
No sir i will not include any spaces at all. If i will input pauledward it must be p,a,u,l,e,d,w,a,r,d and there is no spaces will be put and how to do that will the data is typing?
ridoy 28-Jul-13 6:30am    
in your textbox textchanged event put comma after every occasion of textchanged events,that means after every letter.
Crixalis Paul 28-Jul-13 6:31am    
How is the code for that sir?
I am only new in this programming

string s1 = "Welcome";
string s2 = String.Join(".",s1.Text.ToCharArray().Select(x => x.ToString () + ",").ToArray());
 
Share this answer
 
v4
Comments
Joezer BH 28-Jul-13 7:52am    
Don't forget to remove the last ',' ...
Crixalis Paul 28-Jul-13 8:06am    
this is not working sir in the textchanged event
Maciej Los 28-Jul-13 15:32pm    
What you mean: "This is not working"?
Yesudasan Moses 29-Jul-13 5:00am    
Its C#.NET Code... CHange it to VB.NET
Here is a little code:

When you type, add a comma. When you backspace, remove comma and last char.

VB
  'to remove the last char and its comma
    Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode = Keys.Back Then
            If TextBox1.Text.Count > 2 Then
                TextBox1.Text = TextBox1.Text.Substring(0, TextBox1.Text.Length - 2)


'always move the cursor back to the end so you can keep typing
            TextBox1.Select(TextBox1.Text.Length, 0)
            End If
        End If
    End Sub


    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        If Not TextBox1.Text.Last = "," Then
            TextBox1.Text = TextBox1.Text & ","

            'always move the cursor back to the end so you can keep typing
            TextBox1.Select(TextBox1.Text.Length, 0)
        End If
    End Sub
 
Share this answer
 
v3
Comments
Mr.TMG 28-Jul-13 15:44pm    
Now that code that i posted is faulty. you cannot delete the first char. But ahopefuly this should get you started

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900