Do you see anything concerning? Would you do something differently? Any comments?
public partial class mainForm : Form
{
public mainForm()
{
InitializeComponent();
}
// String array
private string[] myWords = new string[4];
private string currentWord;
private int wordIndex;
private void parseWords()
{
myWords[0] = "The ";
myWords[1] = "fox ";
myWords[2] = "jumps ";
myWords[3] = "slowly.";
currentWord = myWords[0];
txtWordDisplay.Text = currentWord;
wordIndex = 1;
}
private bool nextWord(int wordIndexSet)
{
// Make sure it's not the last element
if (wordIndexSet != myWords.Length)
{
int arrayIndex;
wordIndex++;
arrayIndex = wordIndex - 1;
currentWord = myWords[arrayIndex];
txtWordDisplay.Text = currentWord;
return true;
}
else
{
return false;
}
}
private void button1_Click(object sender, EventArgs e)
{
parseWords();
txtWordDisplay.Enabled = true;
lblToType.Enabled = true;
txtInput.Enabled = true;
}
private void txtInput_TextChanged(object sender, EventArgs e)
{
if (txtInput.Text == currentWord)
{
txtInput.Text = "";
if (nextWord(wordIndex))
{
// Carry on typing...
}
else
{
txtInput.Enabled = false;
MessageBox.Show("Finished!");
}
}
}
}
Basically, the program loads, you click the start button, it enables the textbox for you to type in, it shows you a word to type and you type it, if it matches it empties the text box and you start with the next word until it reaches the last word.
I do have one question, how do I rename button1_Click, I've renamed it directly in visual studio (via the properties window) but it hasn't updated in the codeview?
Thank you :)