Using user input numbers to find a word in a textbox
Currently trying to work out how I use user inputs. In my case it is 1/2/3 to find a specific line and word in a text box and copy that information and output the word into a new text box. The text box the user inputs into has already been split so the first number chooses the text file to choose a word from the second number chooses a line and the third number chooses a word. After the first number is read the chosen text file is going to be output into a rich text box before the keyword is discovered and output.
So far I don't have much code towards this but the only part I really don't understand is how to find the specific line and word. Currently the text box with the three user inputs is being broken up into each individual section and being stored in invisible labels for each section as you can see in my code.
Here's my code so far:
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# textbox line
add a comment |
Currently trying to work out how I use user inputs. In my case it is 1/2/3 to find a specific line and word in a text box and copy that information and output the word into a new text box. The text box the user inputs into has already been split so the first number chooses the text file to choose a word from the second number chooses a line and the third number chooses a word. After the first number is read the chosen text file is going to be output into a rich text box before the keyword is discovered and output.
So far I don't have much code towards this but the only part I really don't understand is how to find the specific line and word. Currently the text box with the three user inputs is being broken up into each individual section and being stored in invisible labels for each section as you can see in my code.
Here's my code so far:
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# textbox line
Can you also share some input file data and the expected output? Based on1how do you decide which file to read? Do you need to read locate file from some specific location?
– Chetan Ranpariya
Nov 13 '18 at 11:25
Are the File listed somewhere (aList<string>or similar)? DoeslblLine.Textreferences the Line number in which a Word should be found? IslblWord.Textthe Word index in the sequence of words in a Line?
– Jimi
Nov 13 '18 at 12:00
var charArray = txtPoemInput.Text.Split('/');Don't assume you will have three parts in your string. Always check.
– LarsTech
Nov 13 '18 at 16:27
The labels or lbl's are used to define each of the sections i have to use. The poem one selects one of three poems to use. The line value needs to find that line in the pome ( which once found will be output to the screen into a rich text box) and the word should hopefully find the word in that line. E.G. 1/2/3 would be poem one line 2 word three. I asked my c' teacher he suggested I use invisible list boxes to count the lines and then use a second one to count the words by splitting them with space instead of the slash like i did earlier. Hope this helps clarify.
– Jack McLoughlin
Nov 15 '18 at 15:52
add a comment |
Currently trying to work out how I use user inputs. In my case it is 1/2/3 to find a specific line and word in a text box and copy that information and output the word into a new text box. The text box the user inputs into has already been split so the first number chooses the text file to choose a word from the second number chooses a line and the third number chooses a word. After the first number is read the chosen text file is going to be output into a rich text box before the keyword is discovered and output.
So far I don't have much code towards this but the only part I really don't understand is how to find the specific line and word. Currently the text box with the three user inputs is being broken up into each individual section and being stored in invisible labels for each section as you can see in my code.
Here's my code so far:
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# textbox line
Currently trying to work out how I use user inputs. In my case it is 1/2/3 to find a specific line and word in a text box and copy that information and output the word into a new text box. The text box the user inputs into has already been split so the first number chooses the text file to choose a word from the second number chooses a line and the third number chooses a word. After the first number is read the chosen text file is going to be output into a rich text box before the keyword is discovered and output.
So far I don't have much code towards this but the only part I really don't understand is how to find the specific line and word. Currently the text box with the three user inputs is being broken up into each individual section and being stored in invisible labels for each section as you can see in my code.
Here's my code so far:
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# textbox line
c# textbox line
edited Nov 13 '18 at 16:22
user6910411
33.9k1079101
33.9k1079101
asked Nov 13 '18 at 11:20
Jack McLoughlinJack McLoughlin
134
134
Can you also share some input file data and the expected output? Based on1how do you decide which file to read? Do you need to read locate file from some specific location?
– Chetan Ranpariya
Nov 13 '18 at 11:25
Are the File listed somewhere (aList<string>or similar)? DoeslblLine.Textreferences the Line number in which a Word should be found? IslblWord.Textthe Word index in the sequence of words in a Line?
– Jimi
Nov 13 '18 at 12:00
var charArray = txtPoemInput.Text.Split('/');Don't assume you will have three parts in your string. Always check.
– LarsTech
Nov 13 '18 at 16:27
The labels or lbl's are used to define each of the sections i have to use. The poem one selects one of three poems to use. The line value needs to find that line in the pome ( which once found will be output to the screen into a rich text box) and the word should hopefully find the word in that line. E.G. 1/2/3 would be poem one line 2 word three. I asked my c' teacher he suggested I use invisible list boxes to count the lines and then use a second one to count the words by splitting them with space instead of the slash like i did earlier. Hope this helps clarify.
– Jack McLoughlin
Nov 15 '18 at 15:52
add a comment |
Can you also share some input file data and the expected output? Based on1how do you decide which file to read? Do you need to read locate file from some specific location?
– Chetan Ranpariya
Nov 13 '18 at 11:25
Are the File listed somewhere (aList<string>or similar)? DoeslblLine.Textreferences the Line number in which a Word should be found? IslblWord.Textthe Word index in the sequence of words in a Line?
– Jimi
Nov 13 '18 at 12:00
var charArray = txtPoemInput.Text.Split('/');Don't assume you will have three parts in your string. Always check.
– LarsTech
Nov 13 '18 at 16:27
The labels or lbl's are used to define each of the sections i have to use. The poem one selects one of three poems to use. The line value needs to find that line in the pome ( which once found will be output to the screen into a rich text box) and the word should hopefully find the word in that line. E.G. 1/2/3 would be poem one line 2 word three. I asked my c' teacher he suggested I use invisible list boxes to count the lines and then use a second one to count the words by splitting them with space instead of the slash like i did earlier. Hope this helps clarify.
– Jack McLoughlin
Nov 15 '18 at 15:52
Can you also share some input file data and the expected output? Based on
1 how do you decide which file to read? Do you need to read locate file from some specific location?– Chetan Ranpariya
Nov 13 '18 at 11:25
Can you also share some input file data and the expected output? Based on
1 how do you decide which file to read? Do you need to read locate file from some specific location?– Chetan Ranpariya
Nov 13 '18 at 11:25
Are the File listed somewhere (a
List<string> or similar)? Does lblLine.Text references the Line number in which a Word should be found? Is lblWord.Text the Word index in the sequence of words in a Line?– Jimi
Nov 13 '18 at 12:00
Are the File listed somewhere (a
List<string> or similar)? Does lblLine.Text references the Line number in which a Word should be found? Is lblWord.Text the Word index in the sequence of words in a Line?– Jimi
Nov 13 '18 at 12:00
var charArray = txtPoemInput.Text.Split('/'); Don't assume you will have three parts in your string. Always check.– LarsTech
Nov 13 '18 at 16:27
var charArray = txtPoemInput.Text.Split('/'); Don't assume you will have three parts in your string. Always check.– LarsTech
Nov 13 '18 at 16:27
The labels or lbl's are used to define each of the sections i have to use. The poem one selects one of three poems to use. The line value needs to find that line in the pome ( which once found will be output to the screen into a rich text box) and the word should hopefully find the word in that line. E.G. 1/2/3 would be poem one line 2 word three. I asked my c' teacher he suggested I use invisible list boxes to count the lines and then use a second one to count the words by splitting them with space instead of the slash like i did earlier. Hope this helps clarify.
– Jack McLoughlin
Nov 15 '18 at 15:52
The labels or lbl's are used to define each of the sections i have to use. The poem one selects one of three poems to use. The line value needs to find that line in the pome ( which once found will be output to the screen into a rich text box) and the word should hopefully find the word in that line. E.G. 1/2/3 would be poem one line 2 word three. I asked my c' teacher he suggested I use invisible list boxes to count the lines and then use a second one to count the words by splitting them with space instead of the slash like i did earlier. Hope this helps clarify.
– Jack McLoughlin
Nov 15 '18 at 15:52
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279916%2fusing-user-input-numbers-to-find-a-word-in-a-textbox%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53279916%2fusing-user-input-numbers-to-find-a-word-in-a-textbox%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you also share some input file data and the expected output? Based on
1how do you decide which file to read? Do you need to read locate file from some specific location?– Chetan Ranpariya
Nov 13 '18 at 11:25
Are the File listed somewhere (a
List<string>or similar)? DoeslblLine.Textreferences the Line number in which a Word should be found? IslblWord.Textthe Word index in the sequence of words in a Line?– Jimi
Nov 13 '18 at 12:00
var charArray = txtPoemInput.Text.Split('/');Don't assume you will have three parts in your string. Always check.– LarsTech
Nov 13 '18 at 16:27
The labels or lbl's are used to define each of the sections i have to use. The poem one selects one of three poems to use. The line value needs to find that line in the pome ( which once found will be output to the screen into a rich text box) and the word should hopefully find the word in that line. E.G. 1/2/3 would be poem one line 2 word three. I asked my c' teacher he suggested I use invisible list boxes to count the lines and then use a second one to count the words by splitting them with space instead of the slash like i did earlier. Hope this helps clarify.
– Jack McLoughlin
Nov 15 '18 at 15:52