PC Review


Reply
Thread Tools Rate Thread

during a loop

 
 
Kevin
Guest
Posts: n/a
 
      5th Dec 2008
I'm trying to make what I thought was a simple metronome.

I have a userform with a scroll bar and a toggle button

The toggle buttonn is for the start stop. the scroll bar is for the time
value in between taps.

right now it is working when I start it but then I cannot click on the
toggle button again to get it to stop, or click on the scroll bar to change
the tempo value.

How can I run a loop and stiil be able to click on a button on the user form?


Here is my code...

Private Sub ToggleButton1_Click()
Do While ToggleButton1.Value = True
Sleep ScrollBar1.Value
Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
Loop
End Sub

Thanks
Kevin



 
Reply With Quote
 
 
 
 
Michael
Guest
Posts: n/a
 
      5th Dec 2008
Try using modeless:
UserForm1.Show vbModeless
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"Kevin" wrote:

> I'm trying to make what I thought was a simple metronome.
>
> I have a userform with a scroll bar and a toggle button
>
> The toggle buttonn is for the start stop. the scroll bar is for the time
> value in between taps.
>
> right now it is working when I start it but then I cannot click on the
> toggle button again to get it to stop, or click on the scroll bar to change
> the tempo value.
>
> How can I run a loop and stiil be able to click on a button on the user form?
>
>
> Here is my code...
>
> Private Sub ToggleButton1_Click()
> Do While ToggleButton1.Value = True
> Sleep ScrollBar1.Value
> Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
> Loop
> End Sub
>
> Thanks
> Kevin
>
>
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      5th Dec 2008
I always use Ctl + Break, but then I am old fashioned. Obviouly I don't know
of a way to break a loop with a button or any other type control without
entering break mode, or doing a hard stop with Ctl + Alt + Delete. But I
never claimed to be a genius at this stuff either.

"Kevin" wrote:

> I'm trying to make what I thought was a simple metronome.
>
> I have a userform with a scroll bar and a toggle button
>
> The toggle buttonn is for the start stop. the scroll bar is for the time
> value in between taps.
>
> right now it is working when I start it but then I cannot click on the
> toggle button again to get it to stop, or click on the scroll bar to change
> the tempo value.
>
> How can I run a loop and stiil be able to click on a button on the user form?
>
>
> Here is my code...
>
> Private Sub ToggleButton1_Click()
> Do While ToggleButton1.Value = True
> Sleep ScrollBar1.Value
> Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
> Loop
> End Sub
>
> Thanks
> Kevin
>
>
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      5th Dec 2008
What you can do is either set a limit with a counter or use the OnTime method
to turn it off.

"Kevin" wrote:

> I'm trying to make what I thought was a simple metronome.
>
> I have a userform with a scroll bar and a toggle button
>
> The toggle buttonn is for the start stop. the scroll bar is for the time
> value in between taps.
>
> right now it is working when I start it but then I cannot click on the
> toggle button again to get it to stop, or click on the scroll bar to change
> the tempo value.
>
> How can I run a loop and stiil be able to click on a button on the user form?
>
>
> Here is my code...
>
> Private Sub ToggleButton1_Click()
> Do While ToggleButton1.Value = True
> Sleep ScrollBar1.Value
> Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
> Loop
> End Sub
>
> Thanks
> Kevin
>
>
>

 
Reply With Quote
 
Kevin
Guest
Posts: n/a
 
      6th Dec 2008
I did try modeless with no luck. mayber there is a different way to go about
this...
What I want to happen is to get a tap sound every millisecond that is
defined by the scroll bar value.
I would like to be able to change the scroll bar value as its tapping and
have it increase or decrease accordingly. And of course start and stop when
the button is clicked. Is there some way better than a simple loop to do
this?

Thanks again,
Kevin


"JLGWhiz" wrote:

> What you can do is either set a limit with a counter or use the OnTime method
> to turn it off.
>
> "Kevin" wrote:
>
> > I'm trying to make what I thought was a simple metronome.
> >
> > I have a userform with a scroll bar and a toggle button
> >
> > The toggle buttonn is for the start stop. the scroll bar is for the time
> > value in between taps.
> >
> > right now it is working when I start it but then I cannot click on the
> > toggle button again to get it to stop, or click on the scroll bar to change
> > the tempo value.
> >
> > How can I run a loop and stiil be able to click on a button on the user form?
> >
> >
> > Here is my code...
> >
> > Private Sub ToggleButton1_Click()
> > Do While ToggleButton1.Value = True
> > Sleep ScrollBar1.Value
> > Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
> > Loop
> > End Sub
> >
> > Thanks
> > Kevin
> >
> >
> >

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      6th Dec 2008
I have never reallly thought about that aspect before, but I do have some
loops that change font size and color on a random basis. However, these are
ran to a fixed limit of loops with a counter or length of text, etc. Here is
a clunge job that allows you to change the frequency of the beep by changing
the delay time. I started with a value of 2 in cell B2 and changed it to 10,
5 , 1 and 0 to see if I could detect the tempo change and it seemed to work.
Maybe you can adapt it to your situation.



"Kevin" wrote:

> I did try modeless with no luck. mayber there is a different way to go about
> this...
> What I want to happen is to get a tap sound every millisecond that is
> defined by the scroll bar value.
> I would like to be able to change the scroll bar value as its tapping and
> have it increase or decrease accordingly. And of course start and stop when
> the button is clicked. Is there some way better than a simple loop to do
> this?
>
> Thanks again,
> Kevin
>
>
> "JLGWhiz" wrote:
>
> > What you can do is either set a limit with a counter or use the OnTime method
> > to turn it off.
> >
> > "Kevin" wrote:
> >
> > > I'm trying to make what I thought was a simple metronome.
> > >
> > > I have a userform with a scroll bar and a toggle button
> > >
> > > The toggle buttonn is for the start stop. the scroll bar is for the time
> > > value in between taps.
> > >
> > > right now it is working when I start it but then I cannot click on the
> > > toggle button again to get it to stop, or click on the scroll bar to change
> > > the tempo value.
> > >
> > > How can I run a loop and stiil be able to click on a button on the user form?
> > >
> > >
> > > Here is my code...
> > >
> > > Private Sub ToggleButton1_Click()
> > > Do While ToggleButton1.Value = True
> > > Sleep ScrollBar1.Value
> > > Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
> > > Loop
> > > End Sub
> > >
> > > Thanks
> > > Kevin
> > >
> > >
> > >

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      6th Dec 2008
P.S. The delay is in seconds.

"Kevin" wrote:

> I did try modeless with no luck. mayber there is a different way to go about
> this...
> What I want to happen is to get a tap sound every millisecond that is
> defined by the scroll bar value.
> I would like to be able to change the scroll bar value as its tapping and
> have it increase or decrease accordingly. And of course start and stop when
> the button is clicked. Is there some way better than a simple loop to do
> this?
>
> Thanks again,
> Kevin
>
>
> "JLGWhiz" wrote:
>
> > What you can do is either set a limit with a counter or use the OnTime method
> > to turn it off.
> >
> > "Kevin" wrote:
> >
> > > I'm trying to make what I thought was a simple metronome.
> > >
> > > I have a userform with a scroll bar and a toggle button
> > >
> > > The toggle buttonn is for the start stop. the scroll bar is for the time
> > > value in between taps.
> > >
> > > right now it is working when I start it but then I cannot click on the
> > > toggle button again to get it to stop, or click on the scroll bar to change
> > > the tempo value.
> > >
> > > How can I run a loop and stiil be able to click on a button on the user form?
> > >
> > >
> > > Here is my code...
> > >
> > > Private Sub ToggleButton1_Click()
> > > Do While ToggleButton1.Value = True
> > > Sleep ScrollBar1.Value
> > > Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
> > > Loop
> > > End Sub
> > >
> > > Thanks
> > > Kevin
> > >
> > >
> > >

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      6th Dec 2008
Probably would help if I posted the code also. It will not work at less than
one second, apparently because there is not enough time in the DoEvents to
proocess the allow the change to process.

Sub freq()
Dim i As Long, s As Double
i = Range("B2").Value
Do Until counter = 30
If i <> Range("B2").Value Then
i = Range("B2").Value
End If
Beep
s = Timer + i
Do While Timer < s
DoEvents
Loop
Beep
Loop
End Sub


"Kevin" wrote:

> I did try modeless with no luck. mayber there is a different way to go about
> this...
> What I want to happen is to get a tap sound every millisecond that is
> defined by the scroll bar value.
> I would like to be able to change the scroll bar value as its tapping and
> have it increase or decrease accordingly. And of course start and stop when
> the button is clicked. Is there some way better than a simple loop to do
> this?
>
> Thanks again,
> Kevin
>
>
> "JLGWhiz" wrote:
>
> > What you can do is either set a limit with a counter or use the OnTime method
> > to turn it off.
> >
> > "Kevin" wrote:
> >
> > > I'm trying to make what I thought was a simple metronome.
> > >
> > > I have a userform with a scroll bar and a toggle button
> > >
> > > The toggle buttonn is for the start stop. the scroll bar is for the time
> > > value in between taps.
> > >
> > > right now it is working when I start it but then I cannot click on the
> > > toggle button again to get it to stop, or click on the scroll bar to change
> > > the tempo value.
> > >
> > > How can I run a loop and stiil be able to click on a button on the user form?
> > >
> > >
> > > Here is my code...
> > >
> > > Private Sub ToggleButton1_Click()
> > > Do While ToggleButton1.Value = True
> > > Sleep ScrollBar1.Value
> > > Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
> > > Loop
> > > End Sub
> > >
> > > Thanks
> > > Kevin
> > >
> > >
> > >

 
Reply With Quote
 
Kevin
Guest
Posts: n/a
 
      9th Dec 2008

Duh, ok one little piece was missing out of my code and I didn't catch it in
any of your examples either... Finally caught my eye in the help menu under
timer.. :-)

"DoEvents"

When I put that intot he code I had it then yoelds to other process like
clicking the start/stop button or changing the scroll bar value...


Private Sub ToggleButton1_Click()
Do While ToggleButton1.Value = True
DoEvents
Sleep ScrollBar1.Value
Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
Loop
End Sub


"JLGWhiz" wrote:

> Probably would help if I posted the code also. It will not work at less than
> one second, apparently because there is not enough time in the DoEvents to
> proocess the allow the change to process.
>
> Sub freq()
> Dim i As Long, s As Double
> i = Range("B2").Value
> Do Until counter = 30
> If i <> Range("B2").Value Then
> i = Range("B2").Value
> End If
> Beep
> s = Timer + i
> Do While Timer < s
> DoEvents
> Loop
> Beep
> Loop
> End Sub
>
>
> "Kevin" wrote:
>
> > I did try modeless with no luck. mayber there is a different way to go about
> > this...
> > What I want to happen is to get a tap sound every millisecond that is
> > defined by the scroll bar value.
> > I would like to be able to change the scroll bar value as its tapping and
> > have it increase or decrease accordingly. And of course start and stop when
> > the button is clicked. Is there some way better than a simple loop to do
> > this?
> >
> > Thanks again,
> > Kevin
> >
> >
> > "JLGWhiz" wrote:
> >
> > > What you can do is either set a limit with a counter or use the OnTime method
> > > to turn it off.
> > >
> > > "Kevin" wrote:
> > >
> > > > I'm trying to make what I thought was a simple metronome.
> > > >
> > > > I have a userform with a scroll bar and a toggle button
> > > >
> > > > The toggle buttonn is for the start stop. the scroll bar is for the time
> > > > value in between taps.
> > > >
> > > > right now it is working when I start it but then I cannot click on the
> > > > toggle button again to get it to stop, or click on the scroll bar to change
> > > > the tempo value.
> > > >
> > > > How can I run a loop and stiil be able to click on a button on the user form?
> > > >
> > > >
> > > > Here is my code...
> > > >
> > > > Private Sub ToggleButton1_Click()
> > > > Do While ToggleButton1.Value = True
> > > > Sleep ScrollBar1.Value
> > > > Application.Run "tap" ' Plays C:\WINDOWS\Media\start.Wav
> > > > Loop
> > > > End Sub
> > > >
> > > > Thanks
> > > > Kevin
> > > >
> > > >
> > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Simple window application with a loop and a button to eventuallystop the loop Joe Cool Microsoft C# .NET 15 29th Jul 2009 08:40 PM
returning back to loop check condition without completing the loop ashish128 Microsoft Excel Programming 13 3rd Apr 2008 12:53 PM
loop through field names, then use to loop through records topopulate grid pmacdiddie@gmail.com Microsoft Access Form Coding 1 4th Jan 2008 01:13 PM
Advancing outer Loop Based on criteria of inner loop =?Utf-8?B?RXhjZWxNb25rZXk=?= Microsoft Excel Programming 1 15th Aug 2005 05:23 PM
Convert loop with Match function to avoid nested loop??? Kobayashi Microsoft Excel Programming 2 17th Mar 2004 06:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:02 PM.