首页 > 解决方案 > 使用用户输入的数字在文本框中查找单词

问题描述

目前正在尝试弄清楚我如何使用用户输入。在我的情况下,在文本框中找到特定的行和单词并复制该信息并将单词输出到新的文本框中是 1/2/3。用户输入的文本框已经被拆分,因此第一个数字选择文本文件以从第二个数字选择一个单词,第三个数字选择一个单词。在读取第一个数字后,所选文本文件将在发现和输出关键字之前输出到富文本框中。

到目前为止,我对此没有太多代码,但我真正不明白的唯一部分是如何找到特定的行和单词。目前,具有三个用户输入的文本框被分解为每个单独的部分,并存储在每个部分的不可见标签中,正如您在我的代码中看到的那样。

到目前为止,这是我的代码:

public partial class Form1 : Form
{
    int NumLines;
    public Form1()
    {
        InitializeComponent();
    }

    private void btnSubmit1_Click(object sender, EventArgs e)
    {
        var charArray = txtPoemInput.Text.Split('/');   // Dividing the users input into 3 usable sections using invisible labels

        lblPoem.Text = charArray[0];    
        lblLine.Text = charArray[1];
        lblWord.Text = charArray[2];



        // Testing for which poem is going to be used
        if (lblPoem.Text == "1")
        {
            //Read in text file
        }
        else if (lblPoem.Text == "2")
        {
            //Read in text file
        }
        else if (lblPoem.Text == "3")
        {
            //Read in text file
        }

        NumLines = txtPoem.Lines.Count();

        // the user input line and word finds and selects the speciic word required 
        // Displays word in the Keyword box 

标签: c#textboxline

解决方案


推荐阅读