Home > Software engineering >  VB on how to return a form, please
VB on how to return a form, please

Time:10-01

User runs, returns on a user just visit form

CodePudding user response:

Unlike industrial control software, the expression is very difficult to explain

CodePudding user response:

reference 1st floor bakw response:
unlike industrial control software, the expression is hard to explain

That is like the browser's back button

CodePudding user response:

The form? Before opening a new form, with a global variables to save the current form,

CodePudding user response:

reference Runnerchin reply: 3/f
form? Before opening a new form, with a global variables to save the current form of


Can you come to a demonstration

CodePudding user response:

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?
. .

CodePudding user response:

Vb is a collection of forms, including all open form (of course, don't quit only hidden form), as long as you find the corresponding index, can follow one's inclinations...

Try it,

CodePudding user response:

Is just to write this function before, in fact, after is simple:
As long as the level in each form to apply for a form of Public variables can be:

 
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


Is the window as a linked list.
Because, of course, under the open a form when unload the current forms, so can only take a step back.
If you want to keep all the previous steps, that only to establish a special engineering level of the public list. The principle, implementation is easy.

CodePudding user response:

I wrote a simple example (forms, control object no change name, such as button is only to change a Caption attribute) :

Create a new standard EXE engineering ", add a form Form2,
Form1 painting of a ListBox, a button (display window),
Form2 painting of two buttons: Command1 before (window), Command2 after (window),
The code is as follows:
 '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

CodePudding user response:

"Window list" any of the window, can be closed at any time,
In the middle of the chain of "window" to close the window, automatically activated "one window",
At the end of the chain of "window" point "in the next window", a window is a new window,

CodePudding user response:

reference 5 floor bakw reply:
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?
. .
on the standard modulenullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related