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

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

Private Sub Timer1_Timer()
   If bBigToSmall = False Then
      Shape1.Width = Shape1.Width + 100
      Shape1.Height = Shape1.Height + 100
      iNoOfTimes = iNoOfTimes + 1
      If iNoOfTimes = 3 Then
         bBigToSmall = True
      End If
   Else
      Shape1.Width = Shape1.Width - 100
      Shape1.Height = Shape1.Height - 100
      iNoOfTimes = iNoOfTimes - 1
      If iNoOfTimes = 0 Then
         bBigToSmall = False
      End If
   End If
   'Random Color
   Shape1.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub

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

4) When user Select the Combobox Enable the Timer

Private Sub Combo1_Change()
   Timer1.Enabled = True
End Sub

Private Sub Combo1_Click()
   Combo1_Change
End Sub

5) At last when u desire Disable the timer

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

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

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.

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

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

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

This question has already been answered. Start a new discussion instead.