Results 1 to 5 of 5

Thread: Pulsating Circle

  1. #1
    Guest

    Question

    Ive been trying to make something so that when i press a command buutton, a circle grows bigger then smaller 5 times (like its pulsating) I would like the center of the circle to stay the same while i do this. Ive been able to make it pulsate but only the extreme left edge has stayed in the same place. Does anyone know how to do this?? I would be verry appreciative if you could show me using code, since i am a beginer

    -Steve
    -UserFriendly RULES

  2. #2
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158
    Try the code bellow, yes there may be other more simpler ways off doing this but this isn't bad (what do u people think?) it not hard to understand either!

    Requirements: timer, command button with caption property set to 'Start' as design time and a shape control change shape property to 3-circle, form must be called form1. Let me know how it goes.

    Code:
    Dim grow As String
    Dim growAmount As Integer
    
    Private Sub Command1_Click()
        growAmount = 100 'amount the circle should grow
        grow = "Big"
        If Command1.Caption = "Start" Then
            Timer1.Enabled = True
            Command1.Caption = "Stop"
        Else
            Timer1.Enabled = False
            Command1.Caption = "Start"
        End If
    End Sub
    
    Private Sub Timer1_Timer()
        Select Case grow
            Case "Big"
                Shape1.Width = Shape1.Width + growAmount
                Shape1.Height = Shape1.Height + growAmount
                If Shape1.Width >= 500 Then
                    grow = "Small"
                    Shape1.Width = 500
                    Shape1.Height = 500
                End If
            Case "Small"
                Shape1.Width = Shape1.Width - growAmount
                Shape1.Height = Shape1.Height - growAmount
                If Shape1.Width <= 100 Then
                    grow = "Big"
                    Shape1.Width = 100
                    Shape1.Height = 100
                End If
        End Select
        
        Shape1.Left = (Form1.ScaleWidth - Shape1.Width) / 2
        Shape1.Top = (Form1.ScaleHeight - Shape1.Height) / 2
    End Sub

  3. #3
    Guest
    This is for a class that im taking (sophmore in Hisghschool), and i understand it all except case, since we havnt learned it. Anyone know a way using for...next loops? Thanks for the help though.

    -Steve

  4. #4
    Guest

    Talking WOOOHOOO

    I fixed it. I had to add some modular division to what i had orriginally. here it is

    Code:
    Private Sub Command1_Click()
    
    For y = 1 To 4
    
    For x = 0 To 2000
        c = c + 1
        Shape1.Width = x
        Shape1.Height = x
        If c Mod 2 = 0 Then
            Shape1.Top = Shape1.Top - 1
            Shape1.Left = Shape1.Left - 1
        End If
        Shape1.Visible = True
    Next x
    For x = 2000 To 0 Step -1
    
        c = c - 1
        Shape1.Width = x
        Shape1.Height = x
        If c Mod 2 = 0 Then
            Shape1.Top = Shape1.Top + 1
            Shape1.Left = Shape1.Left + 1
        End If
    Next x
    
    Next y
    End Sub
    thanks for your help Ramandeep.

    -Steve

  5. #5
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158
    SORRY! didn't realise you haven't used case. Glade to hear you worked it out. The Case is similar to the If then Else structure in the sense it is used to compare and execute the appropriate statements but it works much faster. You will learn about it soon.

    The code I wrote I know it's not the best way but that what just come to mind at the time, it does allow you to stop the circle and continue a bit like a pause feature, might be usful in some way?

    Remember there is allways more tha one way of doing somthing!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width