Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Loops

Status
Not open for further replies.

bb11

Programmer
Joined
Feb 23, 2005
Messages
5
Location
AU
Is there a way to change the for loop to something else and to any other loops. How

thanx for your help







float result = float.Parse(memory[0].ToString());


for (int i = 0; i < memory.Count; i++)
{

if (memory.ToString() == "+")
{
result += float.Parse(memory[i + 1].ToString());
TextResult.Text = result.ToString();
}
if (memory.ToString() == "-")
{
result -= float.Parse(memory[i + 1].ToString());
TextResult.Text = result.ToString();
}
if (memory.ToString() == "×")
{
result *= float.Parse(memory[i + 1].ToString());
TextResult.Text = result.ToString();
}
if (memory.ToString() == "÷")
{
result /= float.Parse(memory[i + 1].ToString());
TextResult.Text = result.ToString();
}
 
sorry, but your question isn't making much sense at the moment. perhaps it got truncated.

please could you repost with a little more detail.

many thanks,


mr s. <;)

 
bb11,

Why don't you like the for loop?

I would also suggest changing your if statements to a case/switch statement to help clean up your code. This is generally a good habit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top