Timing frames on a form

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2005
Posts: 8
Reputation: tricia is an unknown quantity at this point 
Solved Threads: 0
tricia tricia is offline Offline
Newbie Poster

Timing frames on a form

 
0
  #1
May 16th, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 11
Reputation: Auron is an unknown quantity at this point 
Solved Threads: 1
Auron's Avatar
Auron Auron is offline Offline
Unverified User

Re: Timing frames on a form

 
0
  #2
May 17th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Timing frames on a form

 
0
  #3
May 17th, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 8
Reputation: tricia is an unknown quantity at this point 
Solved Threads: 0
tricia tricia is offline Offline
Newbie Poster

Re: Timing frames on a form

 
0
  #4
May 17th, 2005
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?






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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Timing frames on a form

 
0
  #5
May 17th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 8
Reputation: tricia is an unknown quantity at this point 
Solved Threads: 0
tricia tricia is offline Offline
Newbie Poster

Re: Timing frames on a form

 
0
  #6
May 17th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Timing frames on a form

 
0
  #7
May 17th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 11
Reputation: Auron is an unknown quantity at this point 
Solved Threads: 1
Auron's Avatar
Auron Auron is offline Offline
Unverified User

Re: Timing frames on a form

 
0
  #8
May 17th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Timing frames on a form

 
0
  #9
May 17th, 2005
Yes, If you could give us a more in depth and elaborate description, I'm sure we could be of more help.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 2567 | Replies: 8
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC