文本框中的拆分字符串 [英] Split String in Text Boxes

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

问题描述




我有TxtLastName,TxtFirstName和TxtMiddleName作为文本框。

但在我的数据库中,记录是Roa,Paul Vista。



如何SPLIT到三个文本框(TxtLastName.text,TxtFirstName.text和TxtMiddleName.text)



谢谢&问候,

PaulAndrewRoa

Hi
I have TxtLastName, TxtFirstName and TxtMiddleName as text boxes.
But in my database the record is Roa, Paul Vista.

how to SPLIT to THREE TEXT BOXES (TxtLastName.text, TxtFirstName.text and TxtMiddleName.text)

Thanks & Regards,
PaulAndrewRoa

推荐答案

好的,我的下一个问题是什么代码首先将它们连接在一起?



没有100%的方式将其恢复为原始格式,因为根据您的显示,不同字段之间没有共同的分隔符。但是你可以做一些有根据的猜测。



我会使用Kenneth提到的Split方法。



第一部分是使用以下内容提取姓氏:

Okay, well my next question is what code joins them together in the first place?

There is no 100% way to get it back in the original format because from what you have shown there is no common deliminator between different fields. But you can make some educated guesses.

I would use the "Split" method as mentioned by Kenneth.

The first part is to extract the Surname by using something like:
string surnameExtractionArray = Split(completeString, ',');



,根据您在问题中所说的内容,应该返回一个2元素数组。



元素1 =姓氏。



元素2 =字符串的其余部分。



然后我们可以合理地猜测第一个单词是名字。




this, based on what you have said in your question should return an 2 element array.

Element 1 = last name.

Element 2 = the rest of the string.

Then we can make a reasonable guess that the first word is the first name.

string firstName = surnameExtractionArray[1].Trim().Split(',')[0];
string middleNames = surnamExtractionArray[1].Replace(firstName).Trim()





这可能不是最有效的方法,但它应该做你需要的。



This probably isn't the most efficient way of doing this, but it should do what you need.


嗯,首先这里是文档:

http://msdn.microsoft.com/en-us/library/6x627e5f%28v=vs.90%29.aspx [ ^ ]



除此之外,不容易判断你的问题到底是什么。
Well, first off here is the documentation:
http://msdn.microsoft.com/en-us/library/6x627e5f%28v=vs.90%29.aspx[^]

Other than that its not easy to judge what your problem really is.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆