CraigLazar
asked on
Simple Ques on Variables
Hi
how do i declare a variable in my logon screen so it holds the value i give it and then my menu form can see that value ?
i hav tried using the Public tempstatus as integer
but the variable when the app switches to the menu form looses the value
thanx
C
how do i declare a variable in my logon screen so it holds the value i give it and then my menu form can see that value ?
i hav tried using the Public tempstatus as integer
but the variable when the app switches to the menu form looses the value
thanx
C
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
is it in the declarations section?
Start your project from a .BAS MODULE and all vars declared there will be GLOBAL to all forms. You have to tinker with the project properties screen to tell it to start in SUB MAIN
M
M
ASKER
Hi Mirkwood
thanx for your response
i am not following your response clearly
this is what i hav done
'start up is my frmLogon
in Declarations i hav declared my variable
public TempStatus as integer
then according to the User nme and password i set tempStatus
..
..
.
..
Tempstatus = 1
'Then i call my menu form
load frmMenu
frmMenu.show
'I need tempstatus to hold its value in the menu form because i am disabling some of my menu options according to the value of Temstatus
i hope this will help, I do not know if it is the write way to do it . i tried Mark2150 suggestion and it still looses it'e value
thanx allot mate
C
thanx for your response
i am not following your response clearly
this is what i hav done
'start up is my frmLogon
in Declarations i hav declared my variable
public TempStatus as integer
then according to the User nme and password i set tempStatus
..
..
.
..
Tempstatus = 1
'Then i call my menu form
load frmMenu
frmMenu.show
'I need tempstatus to hold its value in the menu form because i am disabling some of my menu options according to the value of Temstatus
i hope this will help, I do not know if it is the write way to do it . i tried Mark2150 suggestion and it still looses it'e value
thanx allot mate
C
put this code in sub main
sub main()
Dim MyLoginForm as new LoginForm
Dim MyMainForm as new MainForm
Load MyLoginForm
Load MyMainForm
MyLoginForm.Show vbModal
MyMainForm.TempVar = MyLoginForm.TempVar
MyMainForm.Show
end sub
Give both MainForm an LoginForm the tempvar variable as public
sub main()
Dim MyLoginForm as new LoginForm
Dim MyMainForm as new MainForm
Load MyLoginForm
Load MyMainForm
MyLoginForm.Show vbModal
MyMainForm.TempVar = MyLoginForm.TempVar
MyMainForm.Show
end sub
Give both MainForm an LoginForm the tempvar variable as public
You may also want to use vb's form properties like:
'Declarations
Private intValue As Integer
Public Property Get Status() As Integer
Status = intValue
End Property
Public Property Let Status(val As Integer)
intValue = val
End Property
The form variable will hold it's value as long as it is still in memory, so you can hide the form, but don't unload.
ed209
'Declarations
Private intValue As Integer
Public Property Get Status() As Integer
Status = intValue
End Property
Public Property Let Status(val As Integer)
intValue = val
End Property
The form variable will hold it's value as long as it is still in memory, so you can hide the form, but don't unload.
ed209