字母之间的逗号 [英] Comma between letters
本文介绍了字母之间的逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想问一些事情。
如何在我想要的任何单词的每个字母中加逗号?以及如何在我当前在文本框中键入数据时执行该代码?并且不要在我要放的第一个字母中包含逗号,请帮助我,因为我发送所有
任何代码都会很棒帮助我和未来谢谢
解决方案
string s1 =Welcome;
string s2 = String.Join(。,s1.Text.ToCharArray()。选择(x => x.ToString()+,)。ToArray());
这是一个小代码:
当你输入时,添加一个逗号。退格时,删除逗号和最后一个字符。
' < span class =code-comment>删除最后一个字符及其逗号
私有 Sub TextBox1_KeyDown(发件人作为 对象,e 正如 KeyEventArgs)句柄 TextBox1.KeyDown
如果 e.KeyCode = Keys。返回然后
如果 TextBox1.Text.Count> 2 然后
TextBox1.Text = TextBox1.Text.Substring( 0 ,TextBox1.Text.Length - 2 )
' 总是将光标移回到最后,这样你就可以继续输入
TextBox1。选择(TextBox1.Text.Length, 0 )
结束 < span class =code-keyword>如果
结束 如果
结束 Sub
私有 Sub TextBox1_TextChanged(发件人作为 对象,e 作为 EventArgs)句柄 TextBox1.TextChanged
如果 不 TextBox1.Text.Last = , 然后
TextBox1.Text = TextBox1.Text& ,
' 始终将光标移回到最后,这样您就可以继续输入
TextBox1。选择(TextBox1.Text.Length, 0 )
结束 如果
结束 Sub
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
解决方案
string s1 = "Welcome";
string s2 = String.Join(".",s1.Text.ToCharArray().Select(x => x.ToString () + ",").ToArray());
Here is a little code:
When you type, add a comma. When you backspace, remove comma and last char.
'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
这篇关于字母之间的逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文