将文本转换为列表 [英] convert text to list

查看:91
本文介绍了将文本转换为列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我有一个文本框,每行包含姓名和空格&地址

示例

Kosay London

Hassan Paris



如何在列表框中列出每个姓名和地址?

结果

Kosay

伦敦

哈桑

巴黎



我使用vb.net 2008

谢谢

Hello
I have a text box each line contain Name & Space & Address
example
Kosay London
Hassan Paris

How I can list each Name and Address in list box ?
the result
Kosay
London
Hassan
Paris

I use vb.net 2008
Thank you

推荐答案

您可以对从TextBox.Text属性获取的字符串使用Split方法,但因为用户不能信任提供格式正确的输入,你可能最好用正则表达式解析字符串以获取项目。
You could use the Split method on the string you get from the TextBox.Text property, but because users cannot be trusted to provide properly formatted input, you''d probably be better off parsing the string with a Regular Expression to get the items.


这篇关于将文本转换为列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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