| | |
Timing frames on a form
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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:
In frmTwo:
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
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)
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
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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?
•
•
Join Date: Feb 2005
Posts: 8
Reputation:
Solved Threads: 0
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?
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:
In frmTwo:Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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:
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.

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)
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. Hey, well let's see.
This is a new variable definition
This code comes under your Form_Load of the form.
This code comes under a timer with the interval set to 1
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.
Hope this helps you, that is if I understand correctly.
This is a new variable definition
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim mCount As Double
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Count = 0 fraOne.Visible = True fraTwo.Visible = True fraThree.Visible = True
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
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
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)
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.
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: VB5 .EXE files/shortcuts & RAM....
- Next Thread: Max number of controls per form......
Views: 2567 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






