?
Solved

command botton switching

Posted on 1997-03-14
1
Medium Priority
?
235 Views
Last Modified: 2012-06-21
I have the following program that runs a collectio of 30 files to create an animation like effect.  I would like to install a slow motion, pause and reverse effect.  I've included code for the slow motion routine.  I would like to take out the radio buttons and put in command buttons.  This way I could prees a button and run the efffect.  I could proably figure out the reverse loop.  What about pause?  How can I get the behaviour to switch when I press the buttons?

thanks


Private Sub cmdOK_Click()
    Unload Form1
End Sub

Private Sub Form_Load()
    Dim nFrame As Single
    Dim sPath As String
   
    ' Put the applications path into a variable
    sPath = App.Path
    ' Check to make sure that the path ends in a "\"
    If Right$(sPath, 1) <> "\" Then sPath = sPath & "\"
   
    ' Centre and show the form
    With Form1
        Left = (Screen.Width - Width) / 2
        Top = (Screen.Height - Height) / 2
        Show
    End With
    DoEvents
   
   
    nFrame = 1
    ' The following loop will run until the program has stopped
    ' but it will not interfere with the operation of the program
    ' at all.
    Do While DoEvents()
        ' The loop will run as long as Doevents returns non-zero.
        ' Doevents() will always return non zero if there is a
        ' form on screen that belongs to this program
   
        ' Load the next image in the sequence into the image control. The images
        ' are all held on the disk as anim0001 to anim0030. The number of the image
        ' to load is held in the nFrame variable.
       If option1 = False Then
        Image1.Picture = LoadPicture(sPath & "anim00" & Format(nFrame, "00") & ".bmp")
        nFrame = nFrame + 1
        If nFrame > 30 Then nFrame = 1
        Else
        Image1.Picture = LoadPicture(sPath & "anim00" & Format(nFrame, "00") & ".bmp")
        nFrame = nFrame + 0.1
        If nFrame > 30 Then nFrame = 1
        End If
       
       
    Loop
   
   
       
   
       
End Sub

0
Comment
Question by:johndill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
Mabry earned 100 total points
ID: 1424315
Use this program.  You'll need to put a timer (named Timer1), picture box on your form (named Image1) and four command buttons (named cmdNormal, cmdSlow, cmdPause, cmdReverse)

I use a timer to manage the animation.  It determines WHEN the new picture is loaded.  The FrameChange variable determines which direction to go (forward = 1, reverse = -1)

I hope this helps ...

-----------------------------------

Dim nFrame As Integer
Dim FrameChange As Integer

Sub Form_Load()
    ' ensure buttons are labeled properly
    cmdNormal.Caption = "Normal"
    cmdPause.Caption = "Pause"
    cmdReverse.Caption = "Reverse"
    cmdSlow.Caption = "Slow"

    ' initialize counters
    nFrame = 1
    FrameChange = 1

    ' start animating at a normal speed    
    cmdNormal_Click
End Sub

Sub Timer1_Timer()
    Image1.Picture = LoadPicture(sPath & "anim00" _
        & Format(nFrame, "00") & ".bmp")
    nFrame = (nFrame + FrameChange + 30) Mod 30
End Sub

' Normal speed, forward
Sub cmdNormal_Click()
    Timer1.Enabled = False
    Timer1.Interval = 55
    FrameChange = 1
    Timer1.Enabled = True
End Sub

' Pause/resume animation
Sub cmdPause_Click()
    If Timer1.Enabled = False Then
        cmdPause.Caption = "Pause"
        Timer1.Enabled = True
    Else
        cmdPause.Caption = "Resume"
        Timer1.Enabled = False
    End If
End Sub

' Slow speed, forward
Sub cmdSlow_Click()
    Timer1.Enabled = False
    Timer1.Interval = 550
    FrameChange = 1
    Timer1.Enabled = True
End Sub

' Normal speed, forward
Sub cmdReverse_Click()
    Timer1.Enabled = False
    Timer1.Interval = 55
    FrameChange = -1
    Timer1.Enabled = True
End Sub

' Slow speed, reverse
Sub cmdReverseSlow_Click()
    Timer1.Enabled = False
    Timer1.Interval = 550
    FrameChange = -1
    Timer1.Enabled = True
End Sub

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question