943,960 Members | Top Members by Rank

Ad:
Jul 18th, 2008
0

Flashing shape !!! ...

Expand Post »
Ok. Need some help with a project at my work. Wanting to create a useful map of the windfarm where I work. (Once completed, will be the largest windfarm in Europe :-))
Anyway have created a map of the site showing the locations of each turbine. Using this map as an image file I added a small circle for each turbine. Once a turbine is selected from a combo box list, the turbine circle is highlighted by changing the circle's colour width and height change (get bigger) to highlight the requested turbine.
Now for the help bit. I want the circle to go large then small, large etc. (ie flash three times and then stay big) I did a For/loop for the three times but can't get the delay to slow down the change. my current code has the click procedure as:

Dim x as Integer

For x = 1 to 3
shape1.colour= (red)
shape1.width= 100
shape1.height= 100
THIS IS WHERE I NEED CODE FOR A DELAY
shape1.colour= (white)
shape1.width=200
shape1.height=200
next x

This changes the circle to white but I've tried timer, another loop etc in the middle but can't get the delay required. As you may gather, I'm a VB newbie, and this may be obvious to some of you how to achieve this. Please reply ASAP, as I'm trying to have this completed over the weekend. Thanks in advance for any help you can offer
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kmacker is offline Offline
12 posts
since Nov 2007
Jul 18th, 2008
0

Re: Flashing shape !!! ...

Hi, Timer will solve your problem.

1) Use a flag variable that indicates bigger to smaller and smaller to bigger as form level.
Dim bBigToSmall as Boolean 
Dim iNoOfTimes As Integer

Private Sub Form_Load()
   bBigToSmall = False
   Timer1.Interval = 100
   Timer1.Enabled = False
End Sub

2) Inside timer, check the Boolean variable
vb Syntax (Toggle Plain Text)
  1. Private Sub Timer1_Timer()
  2. If bBigToSmall = False Then
  3. Shape1.Width = Shape1.Width + 100
  4. Shape1.Height = Shape1.Height + 100
  5. iNoOfTimes = iNoOfTimes + 1
  6. If iNoOfTimes = 3 Then
  7. bBigToSmall = True
  8. End If
  9. Else
  10. Shape1.Width = Shape1.Width - 100
  11. Shape1.Height = Shape1.Height - 100
  12. iNoOfTimes = iNoOfTimes - 1
  13. If iNoOfTimes = 0 Then
  14. bBigToSmall = False
  15. End If
  16. End If
  17. 'Random Color
  18. Shape1.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
  19. End Sub

3) At design time change the Enabled property of the Timer to false

4) When user Select the Combobox Enable the Timer
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Combo1_Change()
  2. Timer1.Enabled = True
  3. End Sub
  4.  
  5. Private Sub Combo1_Click()
  6. Combo1_Change
  7. End Sub
5) At last when u desire Disable the timer
Reputation Points: 44
Solved Threads: 101
Posting Pro
selvaganapathy is offline Offline
547 posts
since Feb 2008
Jul 19th, 2008
0

Re: Flashing shape !!! ...

Fantastic. I changed the combo command to a click, as a button actually selects whats in the combo, but it works brilliant. Thanks for the piece of code. I shall add your name to the credits
Thanks again,

Kenny
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kmacker is offline Offline
12 posts
since Nov 2007
Jul 19th, 2008
0

Re: Flashing shape !!! ...

Hold On! Still a problem. :-(
I have 140 shapes (Shape1 = "T001", Shape2 = "T002" etc). I would like to try and have the program so that, if I select 1 of 140 from a combo box (Eg 39), I only want Shape 39 to flash, then if I select another from the combo (Eg 100), both 39 and 100 will flash. (I already have a reset button which stops everything and returns them to their original condition)
At present I have a combo box where I select a number from T001 to T140, and then click on a "Show"button to trigger it. I'm using Select case so that if combo1.text = T001, then once clicked I want it to flash.
Using your code the shape1 code is in the timer section. How do I set up the timer code so that when each case is selected it then selects the appropriate shape for the timer? (Hope this makes sense)

Help please again
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kmacker is offline Offline
12 posts
since Nov 2007
Jul 19th, 2008
0

Re: Flashing shape !!! ...

Do you have 140 shapes? How do you name the shapes ? Is it shape1, shape2 .... Shape140...

If you have shapes in control array, it will be useful. because we cannot code as many(140) controls.

If you use control array we can access using the index.
Reputation Points: 44
Solved Threads: 101
Posting Pro
selvaganapathy is offline Offline
547 posts
since Feb 2008
Jul 19th, 2008
0

Re: Flashing shape !!! ...

Yes I have 140 shapes named as shape1, shape 2 etc. How would I code a control array. Could you code me for 3 shapes?
On the form there would be a combo box with a list 1-3, and a button to click. Eg select 2 from combo dropdown, click on "Show" button to flash box 2. Then eg select 3 from combo dropdown, click on "Show" button, and both 2 and 3 are flashing. Really appreciate your expert knowledge in helping me.
Kenny
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kmacker is offline Offline
12 posts
since Nov 2007
Jul 20th, 2008
0

Re: Flashing shape !!! ...

To create control array you must do it in design time. When drawing shape form Toolbox to form,

1) First place one shape control and set the properties for the shape. Change the Name of the Shape this will be used for all the controls. It is similar to array in VB.

2) Copy and Paste the Shape ,Vb will ask you to create control array because the shape name already exists. Press yes.

3) Next Paste the as many control as needed your design.

Now your array of controls created
(Shape1(0), Shape1(1), Shape1(2).... Shape1(139) )

Another Way
1- Leave the Control Shape1, You can change the Name property of the Shape2 control to Shape1.
2- For the First time vb will ask Do you want to have control array. Press Yes
3- Then you have to change the Name all other Shapes (Shape3, Shape4, Shape5) in order.

Now these controls are having Same Name Shape1, but different Indexes

I Attach the Example with this
Attached Files
File Type: zip ShapeAnimate.zip (2.6 KB, 50 views)
Reputation Points: 44
Solved Threads: 101
Posting Pro
selvaganapathy is offline Offline
547 posts
since Feb 2008
Jul 21st, 2008
0

Re: Flashing shape !!! ...

Managed to achieve the desired effect using your first random change option, with small size changes. Tidied up some other bits and program now complete. Thanks for all your help and advice. I can hopefully use all this in future projects.

Cheers,

Kenny
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kmacker is offline Offline
12 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: green screen problem
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: sum up a fields





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC