|
-
Nov 8th, 2000, 03:54 PM
#1
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
-
Nov 8th, 2000, 04:30 PM
#2
Addicted Member
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
-
Nov 8th, 2000, 05:41 PM
#3
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
-
Nov 8th, 2000, 05:54 PM
#4
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
-
Nov 9th, 2000, 03:27 PM
#5
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|