|
-
Feb 23rd, 2005, 07:45 PM
#1
Thread Starter
Fanatic Member
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 )
-
Feb 24th, 2005, 04:21 AM
#2
Re: Thinking foward... Execute code once in loop?
You post makes no sense at all.
I don't live here any more.
-
Feb 24th, 2005, 04:22 AM
#3
Re: Thinking foward... Execute code once in loop?
 Originally Posted by wossname
You post makes no sense at all.
that's rude.
-
Feb 24th, 2005, 04:37 AM
#4
Re: Thinking foward... Execute code once in loop?
 Originally Posted by mar_zim
that's rude. 
Just a concise observation. 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.
I don't live here any more.
-
Feb 24th, 2005, 05:34 AM
#5
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.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
-
Feb 28th, 2005, 03:05 PM
#6
Thread Starter
Fanatic Member
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...
-
Feb 28th, 2005, 04:21 PM
#7
Re: Thinking foward... Execute code once in loop?
Then Nope, it would have to be before or after the loop to only execute once.
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|