本文介绍了如何将字符串拆分为两个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我有一个PhoneCode和PhoneNumber分别是文本框
但在我的数据库字段中记录的数据是044-12345678
如何拆分为两个文本框(textbox1.text和textbox2.text)
请为我提供帮助.

谢谢与问候,
rpkaran:rose:

hi
i have a PhoneCode and PhoneNumber are each text boxes
but in my database field record data is 044-12345678
how to SPLIT to TWO TEXT BOXSES (textbox1.text and textbox2.text)
pls help for me.

Thanks & Regards,
rpkaran:rose:

推荐答案

textbox1.text=mystring.split(''-'')[0];
textbox2.text=mystring.split(''-'')[1];




希望对您有所帮助.




Hope this may help you.


string myString = "123-4567890";
string[] parts = myString.Split("-");



此时,parts[0]包含"123",而parts[1]包含"4567890".



At that point, parts[0] contains "123", and parts[1] contains "4567890".


string input = "044-12345678";
 string pattern = "-";            // Split on hyphens

string[] substrings = Regex.Split(input, pattern);
 foreach (string  match in substrings)
 {
     Console.WriteLine("'{0}'", match);

 }




然后将其分配给每个文本框.




and then assign it to each textboxes.


这篇关于如何将字符串拆分为两个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 11:05