bit of vb.net help

Soldato
Joined
11 Jan 2005
Posts
9,961
Location
Birmingham
So I want to make a form that on button click, resizes to a set width (from 250 to 500) with a timer so its "smooth" and not instant.

I can get it to initiate the movement, but then it carries on and by the looks of it my loop goes wild :D


Heres what I have, without the timer part really,

If Me.Width <= 500 Then
Do
Me.Width = Me.Width + 20
Loop Until Me.Width = 500
End If

Btw, I hate programming, so its not great! But howcome my loop doesnt halt when me.width = 500? :confused:


I've no idea how to attempt it with a timer,

everytime timer interval ticks me.width = me.witch + 1 etc..

Help :)
 
... oh yeah :D


hmm, changed it to +10 and still same effect.
Tried +50 too, and it just zoomed to the end of my screen a bit quicker then crashed.



You'd first need to decide how long it should take to resize the form. Once you've decided on that, you need to decide how smooth you want it to be (the smoother you want it, the smaller the timer's interval). Then you can work out the value of increment: increment = (500 - 250) / ((time to resize) / (timer interval)).

Right so, to say ive never used a timer properly before :D
A "normal" speed width expansion of a form would be milliseconds, and the timer interval is based on ms, so if i set the timer interval to say 100 then time to resize represnted by 1 would take 100 passes to reach its destination?

Or I'm way off topic/too ill and bunged up and just dont know :)
 
Last edited:
Back
Top Bottom