Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8556565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:22:54+00:00 2026-06-11T15:22:54+00:00

I have a variable ‘start’ that initializes with a value 0. How can i

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:22:56+00:00Added an answer on June 11, 2026 at 3:22 pm

    I suggest you have a more explicit state variable, and key off of that for all your logic. You’re currently keying off of start only for the transition to sw = true, it’ll be easier if you have an explicit state.

    enum MyState { Part1, Part2, Part3 }
    
    
    MyState currentState = Part1;
    int clickCount = 0;
    
    public void tasbih()
    {
        clickCount++;
    
        // First, do state transitions.
        switch(currentState)
        {
            case MyState.Part1:
                if(clickCount >= 34) { currentState = MyState.Part2; clickCount = 0; } 
                break;
            case MyState.Part2:
                if(clickCount >= 33) { currentState = MyState.Part3; clickCount = 0; } 
                break;
            case MyState.Part3:
                if(clickCount >= 33) { currentState = MyState.Part1; clickCount = 0; } 
                break;
        }
    
        // Now, act on the current (or new) state.
        switch(currentState)
        {
            case MyState.Part1:
                textBlock1.Text = "TEXTBX 1";
                textBlock2.Text = clickCount.ToString();
                break;
            case MyState.Part2:
                textBlock1.Text = "TEXTBX 2";
                textBlock2.Text = clickCount.ToString();
                break;
            case MyState.Part3:
                textBlock1.Text = "ZZZZ";
                textBlock2.Text = clickCount.ToString();
                break;
        }
    }
    
    private void button2_Click(object sender, RoutedEventArgs e)
    {
        currentState = MyState.Part1;
        clickCount = 0;
        tasbih();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have variable $country , it can give ~50 different values. And variable $id
I have variable in tpl file as {assign var=por value=$product.productid} How can I use
I have variable that get's value of checked radio button named: parentcheck I wanna
Possible Duplicate: How can you combine two arrays? I have variable $data1 that contains
I have variable WCHAR sDisplayName[1024]; How can I check if sDisplayName contains the string
How I can have variable number of parameters in my function in C++. Analog
I'm studying javascript these days and I have question. I have variable that contain
I have a variable coming into a stored procedure. This variable can either have
Suppose I have variable x in bash. How can I test if it's some
I know that strings have variable length, therefore they need variable space in memory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.