Time:10-01
CodePudding user response:
unlike industrial control software, the expression is hard to explain
form? Before opening a new form, with a global variables to save the current form of
Option Explicit Public Pfrm As Form Private Sub Command1_Click () Dim As a New Form2 The Set Amy polumbo FRM=Me A.S how The Set Pfrm=Nothing Unload Me End Sub Private Sub Form_Unload (Cancel As Integer) If Not Pfrm Is Nothing Then Pfrm. Show End Sub
'Form1 code (starting form) : Option Explicit Private objFrmHead As Form Public Sub RemoveForm (objNewNext As Form, nFlag As Long) The Set objFrmHead=objNewNext End Sub Private Sub Command1_Click () If (objFrmHead Is Nothing) Then The Set objFrmHead=Form2 Form2. ShowNext Me, 1, 0 Me. List1. AddItem Form2. Caption The Else ObjFrmHead. Show End the If End Sub
'Form2 code: Option Explicit Private objFrmPrev As Form Private objFrmNext As Form Private mlFormID As Long Private mlListID As Long Public Sub ShowNext (objParentForm As Form, nID As Long, ListID As Long) The Set objFrmPrev=objParentForm Caption="window list" & amp; NID Me. Show 0, Form1 MlFormID=nID MlListID=ListID End Sub Public Sub RemoveForm (objNewNext As Form, nFlag As Long) If (nFlag=0) Then The Set objFrmNext=objNewNext The Else The Set objFrmPrev=objNewNext End the If End Sub Public Sub FixListID () 'maintenance main form list with MlListID=mlListID - 1 If (Not objFrmNext Is Nothing) Then Call objFrmNext. FixListID End Sub Private Sub Command1_Click () ObjFrmPrev. Show End Sub Private Sub Command2_Click () If (objFrmNext Is Nothing) Then The Set objFrmNext=New Form2 ObjFrmNext ShowNext Me, mlListID mlFormID + 1, + 1 Form1. List1. AddItem objFrmNext. Caption The Else ObjFrmNext. Show End the If End Sub Private Sub Form_Unload (Cancel As Integer) Call objFrmPrev. RemoveForm (objFrmNext, 0) If (Not objFrmNext Is Nothing) Then Call objFrmNext. RemoveForm (objFrmPrev, 1) Call objFrmNext. FixListID End the If Form1. List1. RemoveItem mlListID ObjFrmPrev. Show 'the two lines below the best don't omit "The Set objFrmPrev=Nothing The Set objFrmNext=Nothing End Sub
this thing can't code, only you want to try and find questions come up, Give you a head, such as note that is only, for example, requires you to think of ) : Public FRM as form Each window set FRM=me when I was lostforce The back button code can write FRM. Show Because the form type is a type of general window, so FRM can be anything you define the form, when lostforce events occur, the window must be a window set FRM=me to convey this window to remember, is to remember on a window, so when the FRM. Show when a window is transferred, But the disadvantage is that can only be returned to the latest window, in order to realize continuous retreat, you want to think about it, then go to achieve, because the code quantity will increase many, understand the words, this is all some manual labor, do not understand, said many also boring, The same process, there are other problems, some window has the time factor, although returned to the previous window, may be not the original content, or maybe the window is not you want to be returned to the window, all of these need you to solve, Also, like public FRM as the form, the sentence should be placed where? . .
Page link:https//www.codepudding.com/Softwareengineering/43778.html