I have a variable ‘start’ that initializes with a value 0.
How can i switch to a different loop when 1 argument becomes true.
So here is what i am trying to accomplish
when I click the button
1st Loop start with textBlock 1 containing “XXXX”
and Variable’Start’ increment’s by 1 everytime i click/touch till it reaches 34 . So when the counter reaches 34, the text changes to ‘YYYY’
2nd Loop is when the counter resets and starts from 0 again but this time it only needs to go up till 33 . As soon as it reaches 33 the text changes to ‘ZZZZ’.
Last Loop: The counter resets agains goes up till 33 . But this time when it finishes. It goes back to loop 1.
Here is the code that i have right now and I cannot seem to figure out how to do the last loop.
public partial class MainPage : PhoneApplicationPage
{
private int start = 0;
private bool sw = false;
// Constructor
public MainPage()
{
InitializeComponent();
int start = 0;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
tasbih();
}
public void tasbih()
{
if (sw == false)
{
textBlock1.Text = "TEXTBX 1";
}
start++;
String text1 = Convert.ToString(start);
textBlock2.Text = text1;
if (start >= 35)
{
textBlock1.Text = "TEXTBX 2";
start = 0;
String text2 = Convert.ToString(start);
textBlock2.Text = text2;
sw = true;
}
}
private void button2_Click(object sender, RoutedEventArgs e)
{
textBlock1.Text = "Reset";
tasbih();
}
Also i have a reset button that starts everything all over no matter where you are in the counter. Any pointers as to how i can do that ?
I suggest you have a more explicit state variable, and key off of that for all your logic. You’re currently keying off of
startonly for the transition tosw = true, it’ll be easier if you have an explicit state.