Exponential increments in a loop
Exponential increments in a loop
Exponential increments in a loop
Exponential increments in a loop
Exponential increments in a loop
Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop
Exponential increments in a loop Exponential increments in a loop
Exponential increments in a loop
Go Back  Xtreme Visual Basic Talk > > > Exponential increments in a loop


Reply
 
Thread Tools Display Modes
  #1  
Old 02-17-2009, 05:07 PM
jfrancis17 jfrancis17 is offline
Newcomer
 
Join Date: Feb 2009
Posts: 1
Default Exponential increments in a loop


Hi, i'm fairly new to VB.

If someone can guide me through with this would be really apreciated.

In a loop, i'm looking to add 1 to Var1's value everytime the loop goes.

I've tried

Dim iCount As Integer

Dim Var1 As Integer

For iCount = 90 To 10 Step (-1 * Var1)
Var1 = 1
Var1 += 1
Me.Opacity = iCount / 100
Me.Refresh()
Threading.Thread.Sleep(35)
Next



Ive also tried to put a For...Next in this For...Next statment..... but the var1 doesnt seem to be reading the changes.

Anybody has a idea..... I hope its clear enough. I understand the For/to/step but how can the step value become exponential ?

THanks for your help
Reply With Quote
  #2  
Old 02-17-2009, 05:41 PM
AtmaWeapon's Avatar
AtmaWeaponExponential increments in a loop AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

It's not working because on every loop you set Var1 to 1. So no matter what, Var1 is always 2 when you calculate the step. Set Var1 to 1 outside of the loop.

It's probably not going to work right anyway, because the form doesn't have to redraw in between the call to Refresh() and Thread.Sleep(). Even if it does, your form is going to be unresponsive. This is work for a worker thread.

I'd encourage a While loop instead; it's much more clear:
Code:
Dim count As Integer = 90
Dim badVariableName As Integer = -1

While count >= 10
    Me.Opacity = count / 100
    Me.Refresh()
    Threading.Thread.Sleep(35)

    count -= badVariableName
    badVariableName -= 1
End While
Any particular reason for such an odd progression of opacity values? This seems like something the WPF was designed to address.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Exponential increments in a loop
Exponential increments in a loop
Exponential increments in a loop Exponential increments in a loop
Exponential increments in a loop
Exponential increments in a loop
Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop Exponential increments in a loop
Exponential increments in a loop
Exponential increments in a loop
 
Exponential increments in a loop
Exponential increments in a loop
 
-->