我如何使我的void编译器读取字符串并在MessageBox中打印它之后的内容
本文关键字:打印 MessageBox 之后 串并 我的 何使 void 编译器 字符串 字符 读取 | 更新日期: 2023-09-27 17:53:11
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void compiler()
{
String print = "print Hello World";
String sP = print.Substring(print.IndexOf(' ') + 1);
MessageBox.Show(sP, "Console");
}
private void TB_TextChanged(object sender, EventArgs e)
{
}
private void runToolStripMenuItem_Click(object sender, EventArgs e)
{
compiler();
}
}
}
我测试了一下,在启动时它打印hello world。现在我只是想让它在文本框中可以读到我输入了"print"和空格后面的内容(例如:"print"<那个空间就在那里)它将打印文本。我希望我说得够清楚了!所以基本上它说的是"打印Hello>
不是很清楚你需要什么,但这可能会有所帮助?
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void compiler()
{
String print = TB.Text;
if (print.ToLowerInvariant().StartsWith("print ")
{
String sP = print.Substring(print.IndexOf(' ') + 1);
MessageBox.Show(sP, "Console");
}
}
private void TB_TextChanged(object sender, EventArgs e)
{
compiler();
}
private void runToolStripMenuItem_Click(object sender, EventArgs e)
{
compiler();
}
}
}