0

This should be easy but ive gotten quite fatigue from coding. I have a multiline textbox which all i need is a loop to count up by 1.5 and the range is from 5 to 23. i found the while loop worked best but i just cant get it to string after each count

double temp=5;
    while (temp > 23)
                    {
                        temp = Convert.ToDouble(textBox7.Text);
                       temp=temp + 1.5;                  

                    }
                    textBox7.Text = temp.ToString();

Thanks for taking a look, i know I will proberly have a face palm moment later

3
Contributors
2
Replies
10
Views
4 Years
Discussion Span
Last Post by ddanbe
0

something like this might work:

for (double i = 5; i <= 23; i += 1.5)
{
    textBox1.AppendText(i.ToString() + "\n");
}

the output is:

[0]: "5"
[1]: "6.5"
[2]: "8"
[3]: "9.5"
[4]: "11"
[5]: "12.5"
[6]: "14"
[7]: "15.5"
[8]: "17"
[9]: "18.5"
[10]: "20"
[11]: "21.5"
[12]: "23"
[13]: ""
1

Your while loop never gets executed with the condition temp > 23 and temp being equal to 5

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.