944,171 Members | Top Members by Rank

Ad:
May 16th, 2005
0

Timing frames on a form

Expand Post »
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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tricia is offline Offline
8 posts
since Feb 2005
May 17th, 2005
0

Re: Timing frames on a form

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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Sub Form_Load()
  2. frmTwo.Show '' Loads up form two
  3. frFirst.Visible = True '' Just make sure the frame is visible
  4. tmrUpdate.Interval = 500 '' This is half a seconds
  5. End Sub
  6.  
  7. Sub tmrUpdate()
  8. if ( frmOne.frFirst.Visible = True ) Then
  9. frmOne.frFirst.Visible = False '' Set the frame on form one invisible
  10. frmTwo.frFirst.Visible = True '' Set the frame on form two visible
  11. End If
  12. tmrUpdate.Interval = 0 '' Just so it won't keep updating
  13. End Sub
In frmTwo:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Sub Form_Load()
  2. frFirst.Visible = False '' The frame needs to be invisible
  3. 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
Reputation Points: 10
Solved Threads: 1
Unverified User
Auron is offline Offline
11 posts
since May 2005
May 17th, 2005
0

Re: Timing frames on a form

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?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
May 17th, 2005
0

Re: Timing frames on a form

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?






Quote originally posted by Auron ...
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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Sub Form_Load()
  2. frmTwo.Show '' Loads up form two
  3. frFirst.Visible = True '' Just make sure the frame is visible
  4. tmrUpdate.Interval = 500 '' This is half a seconds
  5. End Sub
  6.  
  7. Sub tmrUpdate()
  8. if ( frmOne.frFirst.Visible = True ) Then
  9. frmOne.frFirst.Visible = False '' Set the frame on form one invisible
  10. frmTwo.frFirst.Visible = True '' Set the frame on form two visible
  11. End If
  12. tmrUpdate.Interval = 0 '' Just so it won't keep updating
  13. End Sub
In frmTwo:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Sub Form_Load()
  2. frFirst.Visible = False '' The frame needs to be invisible
  3. 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tricia is offline Offline
8 posts
since Feb 2005
May 17th, 2005
0

Re: Timing frames on a form

It works for me

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

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Sub WaitForMSecs(MSecsVar)
  2. Dim Starttime As Single
  3. Starttime = Timer
  4. Do Until Timer >= Starttime + (MSecsVar / 1000)
  5. Doevents ' <<--- Added This Line
  6. Loop
  7. 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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
May 17th, 2005
0

Re: Timing frames on a form

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tricia is offline Offline
8 posts
since Feb 2005
May 17th, 2005
0

Re: Timing frames on a form

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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
May 17th, 2005
0

Re: Timing frames on a form

Hey, well let's see.

This is a new variable definition
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim mCount As Double
This code comes under your Form_Load of the form.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Count = 0
  2. fraOne.Visible = True
  3. fraTwo.Visible = True
  4. fraThree.Visible = True
This code comes under a timer with the interval set to 1
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Count = Count + 1
  2.  
  3. If Count = 500 Then
  4. fraOne.Visible = False
  5. Else If Count = 600 Then
  6. fraTwo.Visible = False
  7. Else If Count = 650 Then
  8. fraThree.Visible = False
  9. 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.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Count = Count + 1
  2.  
  3. If Count = 500 Then
  4. fraOne.Visible = False
  5. Else If Count = 100 Then
  6. fraTwo.Visible = False
  7. Else If Count = 50 Then
  8. fraThree.Visible = False
  9. End If

Hope this helps you, that is if I understand correctly.
Reputation Points: 10
Solved Threads: 1
Unverified User
Auron is offline Offline
11 posts
since May 2005
May 17th, 2005
0

Re: Timing frames on a form

Yes, If you could give us a more in depth and elaborate description, I'm sure we could be of more help.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

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: VB5 .EXE files/shortcuts & RAM....
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Max number of controls per form......





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


Follow us on Twitter


© 2011 DaniWeb® LLC