I need to show three frames consecutively for 500 msecs on a form then move to a new form. I have tried calling a sub procedure to do this but it doesn't work. Can anyone help please?

Well I haven't tried moving a frame from one form to another in VB but why not have it hide the frame on the one form and show it on the other.

Let me give an example:
Create 2 forms, call them frmOne and frmTwo respectively. On each form create a frame, call it frFirst or both forms. Last create a timer on the form you want it to be removed from, call it tmrUpdate.

Ok in frmOne:

Sub Form_Load()
  frmTwo.Show                          '' Loads up form two
  frFirst.Visible = True               '' Just make sure the frame is visible
  tmrUpdate.Interval = 500             '' This is half a seconds
End Sub

Sub tmrUpdate()
  if ( frmOne.frFirst.Visible = True ) Then
    frmOne.frFirst.Visible = False     '' Set the frame on form one invisible
    frmTwo.frFirst.Visible = True      '' Set the frame on form two visible
  End If
  tmrUpdate.Interval = 0               '' Just so it won't keep updating
End Sub

In frmTwo:

Sub Form_Load()
  frFirst.Visible = False              '' The frame needs to be invisible
End Sub

Although this doesn't move the frame from one form to the other it emulates the feeling of doing it, adding all the controls on both frames and setting the values respectively in tmrUpdate

I'm not really sure what you mean by showing frames, or what kind of purpose this would serve.... it sounds to me like there will be 3 fames on 1 form. It will start off with showing frame1, 500ms later will show frame2 and hide frame1, then 500ms later, hide 2 and show frame3. At This point it should load a new form, right? Just to clarify, you are talking about the frame control, not frames of an image, right?

This is very kind of you but I haven't made myself clear - stress setting in from trying to make my program work!

I have 1 form on which there are three frames. Frame 1 must be visible for 500 msecs; frame 2 for 100 msecs and frame 3 for 50 msecs. As I understand VB, this should be possible with a timing sub procedure but while the subprocedure works for forms, I cannot make it work for the frames!

For example:
Sub WaitForMSecs(MSecsVar)
Dim Starttime As Single
Starttime = Timer
Do Until Timer >= Starttime + (MSecsVar / 1000)
Loop
End Sub

So with the code:
frmA.show
fraOne.visible = true
WaitForMSecs 500
fraOne.Visible = False
fraTwo.visible = True
WaitForMSecs 100
fraTwo.Vvisible - False
etc.etc does not work

Any ideas?

Well I haven't tried moving a frame from one form to another in VB but why not have it hide the frame on the one form and show it on the other.

Let me give an example:
Create 2 forms, call them frmOne and frmTwo respectively. On each form create a frame, call it frFirst or both forms. Last create a timer on the form you want it to be removed from, call it tmrUpdate.

Ok in frmOne:

Sub Form_Load()
  frmTwo.Show                          '' Loads up form two
  frFirst.Visible = True               '' Just make sure the frame is visible
  tmrUpdate.Interval = 500             '' This is half a seconds
End Sub

Sub tmrUpdate()
  if ( frmOne.frFirst.Visible = True ) Then
    frmOne.frFirst.Visible = False     '' Set the frame on form one invisible
    frmTwo.frFirst.Visible = True      '' Set the frame on form two visible
  End If
  tmrUpdate.Interval = 0               '' Just so it won't keep updating
End Sub

In frmTwo:

Sub Form_Load()
  frFirst.Visible = False              '' The frame needs to be invisible
End Sub

Although this doesn't move the frame from one form to the other it emulates the feeling of doing it, adding all the controls on both frames and setting the values respectively in tmrUpdate

It works for me ;)

All you should have to do, is modify your sub to contain a doevents, here is the modification:

Sub WaitForMSecs(MSecsVar)
     Dim Starttime As Single
     Starttime = Timer
     Do Until Timer >= Starttime + (MSecsVar / 1000)
          Doevents ' <<--- Added This Line
     Loop
End Sub

Let me know if the doevents fixes your problem. It worked fine on the project I just created and tested.

ps: If you could do me a big favor, and in the future when you post code, add CODE tags around your code. It keeps it formatted and readable. My above post of code is in code tags. IE (with no spaces):

[ CODE ]
Your source code here
[ /CODE ]

:) Thanx in advance.

Thanks to you both but it doesn't work for me. BUT this is probably because I am an experimental psychologist and not a programmer although my skills are growing day by day! I think maybe I'll just have to rethink using VB and learn a language my uni supports!

Thanks anyway

Well if there is anything else we can help you with, or if you can give us a little more information about exactly what your project does, I'd be glad to help you further. Sorry we couldn't give you an answer that fits your resolve, however.

Hey, well let's see.

This is a new variable definition

Dim mCount As Double

This code comes under your Form_Load of the form.

Count = 0
  fraOne.Visible = True
  fraTwo.Visible = True
  fraThree.Visible = True

This code comes under a timer with the interval set to 1

Count = Count + 1

  If Count = 500 Then
    fraOne.Visible = False
  Else If Count = 600 Then
    fraTwo.Visible = False
  Else If Count = 650 Then
    fraThree.Visible = False
  End If

The above code would then after 500ms make frame 1 dissapear, 100ms after that frame 2 would dissapear and 50ms after that frame three will dissapear.

If you want frame 3 to dissapear 50ms after the program start, frame 2 at 100ms and frame 3 at 500ms you would have to use this under the timer rather.

Count = Count + 1

  If Count = 500 Then
    fraOne.Visible = False
  Else If Count = 100 Then
    fraTwo.Visible = False
  Else If Count = 50 Then
    fraThree.Visible = False
  End If

Hope this helps you, that is if I understand correctly.

Yes, If you could give us a more in depth and elaborate description, I'm sure we could be of more help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.