Thinking foward... Execute code once in loop?
I found the Static declaration very useful since you can declare a variable once and let it run threw a loop or sub
ex:
VB Code:
Form_MouseClick
Static Click as Integer = 1
End Sub
which is pretty usefull
anyways, I was wondering if something could do like:
VB Code:
Do
a += 1
b += 2 + a
(Some kind of structure header here)
c=b
(Footer structure here)
Loop
Anyways, to get the result of the c variable only once, meh, I was just curious if some new structure could have 'been created...
Well, .net, let's think foward! :)
(btw don't answer me like use flags and do if statements... There are probably billions of ways to do this, I was just wondering if some new stuff was boiling to be used :))
:wave:
Re: Thinking foward... Execute code once in loop?
You post makes no sense at all.
Re: Thinking foward... Execute code once in loop?
Quote:
Originally Posted by wossname
You post makes no sense at all.
that's rude. :eek:
Re: Thinking foward... Execute code once in loop?
Quote:
Originally Posted by mar_zim
that's rude. :eek:
Just a concise observation. :D No rudeness intended.
I humbly apologise for any anguish, distress or trauma that my earlier comments may have illicited in those of a delicate sensibility.
:bigyello:
Re: Thinking foward... Execute code once in loop?
Can you explain this a little better what you're asking/doing? I also didn't quite understand it.
Re: Thinking foward... Execute code once in loop?
uh, ok, sorry for not being crystal clear...
After using the variable declaration method with Static, that can declare a variable used through let's say a form, the variable is only declared once and it becomes available through the whole form. (lookup "Static" for more info)
Anyways,
I was wondering,
Is there a new way to execute a bunch of code, only once even if it's in a loop?
my previous code:
VB Code:
Do
a += 1
b += 2 + a
(The Function)
c = b
(Footer of function)
Loop Until a = 50
Meaning the c variable will be grabbed ONCE in the loop, regardless of the values changing in the 2nd, 3rd, etc loop.
I think hope it's all clear now...
I know I could use a flag method with an IF to do that, but I'm just exploring new functions...
Re: Thinking foward... Execute code once in loop?
Then Nope, it would have to be before or after the loop to only execute once.