Categories > Coding > C# >

How can i loop that code?

efewss

ecstxsy

Posts: 115

Threads: 14

Joined: Apr, 2021

Reputation: 4

Posted

I want to make a loadbar in wpf. but its not a loadbar actually. It should goes right and left in a loop.

  • 0

my dude entity 🤜🤛

 

https://cdn.discordapp.com/attachments/775762417618780193/978180264037593129/1653286667685.png

Posts: 522

Threads: 29

Joined: Apr, 2021

Reputation: 24

Replied

while (size is not like u want it)

{

   border.width = border.width +5

 

}

 

sorry if this sint correct im on phone rn

  • 0

back lol

efewss

ecstxsy

Posts: 115

Threads: 14

Joined: Apr, 2021

Reputation: 4

Replied

@Lxnnyy

 

its wrong but thats ok thanks anyways

  • 0

my dude entity 🤜🤛

 

https://cdn.discordapp.com/attachments/775762417618780193/978180264037593129/1653286667685.png

eb_

Formally known as Shade

vip

Posts: 1045

Threads: 4

Joined: Jun, 2020

Reputation: 47

Replied

@efewss no your probably just pasting code, not gonna spoon feed you but:

For loop

for (Statement 1; Statement 2; Statement 3) 
{
//Code to execute
}

Foreach loop

foreach (type Variable in Array) 
{
//Code to execute
}

While loop

while (Condition) 
{
//code to execute
}

pretty straightforward.

  • 0

https://media.discordapp.net/attachments/1010636204225601659/1012865624797610044/sKQybOLT.gif

Posts: 870

Threads: 34

Joined: Aug, 2020

Reputation: 6

Replied

all of the replies above do not answer your problem.

for (int I = 0; I < 101; I++)
    this.ProgressBar.Value = I; /* or something */

how can I manually add progress? via method? with breaks?

void SetValue(ProgressBar Bar, int Value) {
    for (int I = 0; I < Value + 1; I++)
          Bar.Value = I;
}

SetValue(MyProgressBar, 100) /* This sets the progressbar's value to 100 percent, This can also be used for Width. */

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/data-types-of-operator-results

Learn more about data types operators like what i used "<"

 

Question: Why did I use for loop? instead of just doing Value = 100?

Answer: if you want it to go smooth it would but remember for loop is fast so you could just like delay to make it even more smoother.

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )