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

Recommended Answers

All 2 Replies

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]: ""

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.