• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

Add stop and resume

hello,
I have two buttons and one listbox
button1 is (Start) button2 is (Resume)
I would like something so that when I click
Start the name changes to Stop and stop the timer.
for the resume if I stop then click on it to resume
where it was! how can I do that ?

>ListBox1
Label1.Text=ListBox1.SelectedItem

>Timer1
If ListBox1.SelectedIndex >= ListBox1.Items.Count -1 Then
       Timer1.Enabled=False
Else
       ListBox1.SelectedIndex=ListBox1.SelectedIndex + 1
End if

>button1
Timer1.Enabled=True
0
aplelois
Asked:
aplelois
  • 3
  • 2
2 Solutions
 
bruintjeCommented:
Hello aplelois,

in your button 1 that should start and stop you can do something like

---------
        If Button1.Text = "Stop" Then
            Button1.Text = "Start"
            Timer1.Enabled = False
            Button2.Enabled = True
        Else
            Button1.Text = "Stop"
            Timer1.Enabled = True
            Button2.Enabled = False
        End If
---------

and in the resume button click

--------
            Button1.Text = "Stop"
            Timer1.Enabled = True
            Button2.Enabled = False
--------

hope this helps a bit
bruintje
0
 
arif_eqbalCommented:
Hi again
It appears that you want something like this....
The Start/Stop button would always start from the first item in the listbox while the Resume button would Resume from the existing index of the List box

Try this...
we would now have two buttons, say the start/stop Button is called Button1 while the resume Button is called ButtonResume

Initially have the Button1 Text as "Start"
Now on Button Click write this

If Button1.Text="Start" then
     ListBox1.SelectedIndex = -1
     Timer1.Enabled = True
     ButtonResume.Enabled=False
     Button1.Text = "Stop"
Else
     Timer1.Enabled=False
     ButtonResume.Enabled=True
     Button1.text = "Start"
End If

Now on ButtonResume Click write this
     Timer1.Enabled = True
     ButtonResume.Enabled=False
     Button1.Text = "Stop"

The rest would be as it is....hope this is what you wanted, otherwise post back here

0
 
arif_eqbalCommented:
Hi bruintje
Sorry was late again :-)
You missed out one thing though....
Say the Timer is Running, and user clicks on STOP to stop the timer, Now we have two options START or RESUME
What I understand is Start should start from the firts item in the listbox while Resume should continue from there.
If that's the case you need to set ListBox1.SelectedIndex=-1 in the Start case
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bruintjeCommented:
yes you are again correct,

@aplelois better ask a moderator to move the points on this question to arif_eqbal

i'll just stay out of EE for a few hours not that sharp :-)
0
 
apleloisAuthor Commented:
thank you guys, you both are the best!
0
 
arif_eqbalCommented:
We are all learning remember :-) and never mind the points again
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now