我需要在textbox1和.................中选择前5个字母。 [英] I need to select the first 5 letters in textbox1 and ..................
本文介绍了我需要在textbox1和.................中选择前5个字母。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要选择textbox1中的前5个字母和文本框2中的前5个字母,并将它们与 - xxxxx-xxxxx分隔成另一个文本框。
任何人都有任何建议?
解决方案
如果你甚至不能尝试这个,你需要购买一本初学者书并阅读它。
string s = textbox1.text.substring(0,5)+ - + textbox2.text.substring(0,5)
当然,如果文本框中的字符少于5个字符,这将会爆炸,你需要添加代码来处理它。一般来说,对于获取ASP.NET,你太过于担心初学者了。首先学习如何做基本代码。
这就是我最终做的事情:感谢Christian的帮助。我最终将它们更改为下拉列表,但它对于文本框的工作方式相同。
Dim mystring As String = DropDownList3.SelectedItem.Text.ToString()
< span class =code-keyword> Dim substring As String = mystring.Substring( 0 , 5 )
Dim mystring2 As String = DropDownList4.SelectedItem.Text.ToString()
Dim substring2 As String = mystring2.Substring ( 0 , 4 )
Dim mystring3 作为 字符串 = TDropDownList.SelectedItem.Text.ToString()
Dim substring3 As String = mystring3.Substring( 0 , 3 )
refnumber.Text = substring + - + substring2 + - + substring3
I need to select the first 5 letters in textbox1 and the first 5 letters in textbox 2 and separate them with a - like: xxxxx-xxxxx into another textbox.
anyone have any suggestions?
解决方案
If you can''t even attempt this, you need to buy a beginners book and read it.
string s = textbox1.text.substring(0,5) + "-" + textbox2.text.substring(0,5)
Of course, this will blow up if there''s less than 5 chars in the textbox, you need to add code to deal with that. and in general, for get ASP.NET, you''re too much of a beginner to worry about that. Learn how to do basic code first.
this is what i ended up doing: thanks for the help though Christian. I ended up changing them to dropdownlists but it works the same for textboxes.
Dim mystring As String = DropDownList3.SelectedItem.Text.ToString() Dim substring As String = mystring.Substring(0, 5) Dim mystring2 As String = DropDownList4.SelectedItem.Text.ToString() Dim substring2 As String = mystring2.Substring(0, 4) Dim mystring3 As String = TDropDownList.SelectedItem.Text.ToString() Dim substring3 As String = mystring3.Substring(0, 3) refnumber.Text = substring + "-" + substring2 + "-" + substring3
这篇关于我需要在textbox1和.................中选择前5个字母。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文