In my code we can see that I am pulling a random line from ListBox by using a random.Next. The problem is that if I want to check the same line for number of characters I’m using a new random number which causes some problems.
How can I use first random number to be used in my IF statement?
SendKeys.Send(lbMessage.Items[random.Next(lbMessage.Items.Count)].
ToString().Substring(currentChar++, 1));
if (currentChar == lbMessage.Items[random.Next(lbMessage.Items.Count)].ToString().Length)
{
SendKeys.Send("{enter}");
tmrSpace.Enabled = false;
currentChar = 0;
}
Save the first random number in a local variable and use it later, like this: