|
-
Mar 17th, 2007, 08:11 AM
#1
Thread Starter
Junior Member
analogue clock
I've a working analogue clock that i've designed using vb.net. How do i do a user interface that enables users to speed or slow down the speed.
-
Mar 17th, 2007, 01:47 PM
#2
Frenzied Member
Re: analogue clock
I don't see how anyone could have any idea without seeing your code.
There are probably 100's of way you could make an analogue clock.
What do you mean:
enables users to speed or slow down the speed
?
Good Luck
-
Mar 17th, 2007, 07:16 PM
#3
Re: analogue clock
Presumably you are using a Timer that Ticks every second to advance the second hand. If you want to speed it up or slow it down you'd reduce or increase the Increment of the Timer. You could use a NumericUpDown control to allow the user to specify the number of milliseconds between Ticks, or you could provide whatever interface you deem appropriate.
Having said that, I would have thought that you'd be getting the current time each Tick and using that to display the time. More frequent Tick events aren't going to change the actual current time.
-
Mar 18th, 2007, 12:04 PM
#4
Thread Starter
Junior Member
Re: analogue clock
This is what i have in the Timer_tick of my code:
NB this is just for the second hand
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim secrad As Single
Dim secdeg As Single
secdeg = (Now.TimeOfDay.Seconds) * 6
secrad = (3.14 / 180) * -sdeg
sechndA = 150 - (90 * Math.Sin(srad))
sechndB = 150 - (90 * Math.Cos(srad))
Me.Invalidate()
In my timer interval i've set it to 1000, I've put the NumericUpDown on the form but how do i associate it with the timer to enable the user to make a choice.
Thank you for the help!
-
Mar 18th, 2007, 04:16 PM
#5
Re: analogue clock
Whenever you want to do something WHEN SOMETHING HAPPENS that immediately means that you need to handle and event, because events are what notify you that something happened. If you want to do something when the Value property of a NumericUpDown changes that means that you need to handle the ValueChanged event. ValueChanged is the default event for the NumericUpDown class so that means that you can just double-click the control in the designer to create the event handler.
Whatever you want to happen is what you put inside the event handler. What you want to happen is that the NUD's Value property is assigned to the Timer's Interval property. Note that NumericUpDown.Value is type Decimal and Timer.Interval is type Integer, so you need to convert from one to the other before the assignment:
vb Code:
myTimer.Interval = Convert.ToInt32(Decimal.Truncate(myNumericUpDown.Value))
-
Mar 19th, 2007, 10:17 AM
#6
Thread Starter
Junior Member
Re: analogue clock
SORRY GUYS I'M SUCH A PEST
No more errors but if i change anything on the NUD in G.U.I nothing seem to be happening, i mean the clock is not slowing down or speeding up. I want to users to be able to make the time go fast or slow through the NUD.
Thank You
Last edited by SpringBok; Mar 19th, 2007 at 04:20 PM.
-
Mar 20th, 2007, 03:45 AM
#7
Re: analogue clock
The Interval property of a Timer controls how often the Tick event is raised. If all you're doing in that Tick event is displaying the current time, or some function of the current time, the how is changing the Interval going to make time speed up or slow down? All it's doing is updating your display more or less often but its still displaying the same value. It's like a CRT monitor and its refresh rate. You can set your monitor to refresh at 60 Hz or 100Hz and it won't make what's happening on screen happen quicker or slower. It just refreshes the view more or less often.
-
Mar 21st, 2007, 11:46 AM
#8
Thread Starter
Junior Member
Re: analogue clock
Thanks jmcilhinney, i'm beginning to understand this language.
Your explanations are spot on. Somethings are purely logical but we tend to miss them sometimes.
Thanks a lot!
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
|