| | |
Retrieving Form Variable
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 56
Reputation:
Solved Threads: 0
I have a routine that, at one step, calls a form and shows it modal. When the user closes the form the routine continues. However, upon closing the form I want to know if it performed its assigned function- if it failed then I need to stop the routine. However, since the form was opened modally and then closed and its memory unloaded at the end, I don't see any way to get any information about what it did. I could have the form trigger a global boolean variable but that does not seem the correct way. There has to be a simple solution, I just can't see it, please help...
•
•
Join Date: Jan 2008
Posts: 56
Reputation:
Solved Threads: 0
Okay, I found something that works but I am still just as confused. In my parent sub I have a variable to the form. I also have given the form a public boolean variable, ConnSuccess, so it goes something like (pseudocode):
So what is the meaning of when the user closes fmConn and it supposedly unloads from memory? Because the fact that I can still read variables and properties inside this form proves that it is still there? Does it only truly go away when I set fmConn1 = Nothing?
•
•
•
•
Sub CreateConn
dim fmConn1 as fmConn
set fmConn1 = new fmConn
fmConn1.Show vbModal
If fmConn1.ConnSuccess then
(etc etc)
Hi,
Global variable or Properties can be used as your suggestion.
Assume you have Ok and Cancel button in your modal form.
In the Modal form, user can click Ok button for approval and for disapproval they can click Cancel Button or Close Button.
When Close button is Clicked the form Unloads from Memory. so u can only receive the default values. At this
When Cancel button is clicked you should hide the form instead unload from memory and Make the Variable False(default value).
When Ok button is clicked here also you should hide the form instead unload from memory and Make the Variable True.
Finally you can unload the form after shown modally.
Ex
Assume this is login form(frmLogin) Cotains Ok and Cancel button
Then you use this login form may be like
Global variable or Properties can be used as your suggestion.
Assume you have Ok and Cancel button in your modal form.
In the Modal form, user can click Ok button for approval and for disapproval they can click Cancel Button or Close Button.
When Close button is Clicked the form Unloads from Memory. so u can only receive the default values. At this
When Cancel button is clicked you should hide the form instead unload from memory and Make the Variable False(default value).
When Ok button is clicked here also you should hide the form instead unload from memory and Make the Variable True.
Finally you can unload the form after shown modally.
Ex
Assume this is login form(frmLogin) Cotains Ok and Cancel button
VB Syntax (Toggle Plain Text)
Public LoginSucceeded As Boolean Private Sub cmdCancel_Click() 'set the global var to false to denote a failed LoginSucceeded = False Me.Hide End Sub Private Sub cmdOK_Click() 'check for Login If DoLogin() Then LoginSucceeded = True Me.Hide Else 'Invalid User Name or Password End If End Sub
VB Syntax (Toggle Plain Text)
Private Sub cmdLogin_Click() Dim fLogin As frmLogin Set fLogin = New frmLogin fLogin.Show vbModal If fLogin.LoginSucceeded Then 'Here Success of Login Else 'Failure of Login End If 'Unload from Memory Unload fLogin End Sub
KSG
I think it's NO. It must be dispose by setting it to Nothing. Unloading the form varaible means you're just closing the form and since you did not dispose the form's variable ergo the variable was still there.
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
•
•
Join Date: Jan 2008
Posts: 56
Reputation:
Solved Threads: 0
•
•
•
•
Unloading the form varaible means you're just closing the form
I admit this is getting a bit away from the original topic, as the above examples already solved my problem. I'm just trying to get a fuller understanding what these commands such as "unload" are really doing.
Hi,
When we use Unload statement the form is getting unload (visible=false) from memory and not destroyed as said by jireh. Then the form is removed from the Forms collection. It is not actually destroyed, until all references to it are set to Nothing. When u call a method or properties of unloaded form, it is again reinitialize all the components so it lost all the previous values
Unload statement fires Query_Unload and Unload events. If you use End statement, it wont fire.
When we use Unload statement the form is getting unload (visible=false) from memory and not destroyed as said by jireh. Then the form is removed from the Forms collection. It is not actually destroyed, until all references to it are set to Nothing. When u call a method or properties of unloaded form, it is again reinitialize all the components so it lost all the previous values
Unload statement fires Query_Unload and Unload events. If you use End statement, it wont fire.
KSG
![]() |
Similar Threads
- Setting up a form in PHP (PHP)
- Retrieving form name (Visual Basic 4 / 5 / 6)
- AJAX generated <select> and FIREFOX (JavaScript / DHTML / AJAX)
- Keeping track of the checkboxes selected acrros the page (PHP)
- Dr Scheme Tutorial (Computer Science)
- Buttons created dynamically VS. events (Python)
- Perl/CGI (Reading Data) Part II (Computer Science)
- mySQL database searching for registration (MySQL)
- Fun with Forms (PHP)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: saving data in sstab
- Next Thread: Hardware interfacing in visual basic
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college 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 number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





