Reputation: 756
The program that i have is supposed to open one link at a time. The timer is set to 10secs. What I want it to do is call the webBrowser1.Navigate(s[x]);
with different values of s[x] every time 10secs pass. I.e. on first Tick I want the s[0] to go to, s[1] when the second tick happens and so on till s[3], then back to s[0].
private void timer1_Tick(object sender, EventArgs e)
{
string[] s = new string[4];
s[0] = textBox1.Text;
s[1] = textBox2.Text;
s[2] = textBox3.Text;
s[3] = textBox4.Text;
webBrowser1.Navigate(s[0]);
}
Upvotes: 0
Views: 529
Reputation: 52808
Just declare a field and increment it each tick.
private int textboxNumber;
private void timer1_Tick(object sender, EventArgs e)
{
string[] s = new string[4];
s[0] = textBox1.Text;
s[1] = textBox2.Text;
s[2] = textBox3.Text;
s[3] = textBox4.Text;
webBrowser1.Navigate(s[textboxNumber]);
textboxNumber++;
if (textboxNumber > 3)
textboxNumber = 0;
}
This probably isn't the best approach to this problem, but it will give you what you want.
Upvotes: 2