我用richtextbox做了个指令框,我想知道怎么获取输入的值
比如:输入
fmov E:\yoli E:\test
这三个值之间用空格隔开,我想把这三个值分别存放到三个变量里该怎么做???
怎么取到这三个值?
补充一点:
richtextbox为多行文本,我输入多行文本后,想取其中一行文本该怎么做???
我用winForm做了个,你看下代码吧:
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string richString = richTextBox1.Text;
string[] richArrayString = richString.Split(' ');
int count = 1;
foreach (string rstr in richArrayString)
{
if (rstr == "fmov" || rstr == "E:\\yoli" || rstr == "E:\\test")
{
string searchString = String.Format("找到的第{0}个相关字符串为:", count) + rstr;
listBox1.Items.Add(searchString);
count++;
}
}
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
}
}
这是程序运行的效果,在右边的listbox显示找到的匹配项!