Solved

Simple Ques on Variables

Posted on 1998-12-15
6
135 Views
Last Modified: 2010-05-03
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
0
Comment
Question by:CraigLazar
6 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 10 total points
ID: 1450205
Login screen is most likely created as
Dim MyloginForm as new LoginForm
MyLoginForm.show

And you access the variable like
LoginForm.PublicVar

LoginForm and MyLoginForm are two instances of the same form now and therefor LoginForm.PublicVar <> MyLoginForm.PublicVar

Declare a public variable in your main form and set its value in the loginForm

Dim MyLoginForm as new LoginForm
Dim MyMainForm as new MainForm

Load MyLoginForm
Load MyMainForm

MyLoginForm.Show vbModal
MyMainForm.PublicVar = MyLoginForm.PublicVar
MyMainForm.Show





0
 
LVL 1

Expert Comment

by:slobstar
ID: 1450206
is it in the declarations section?
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1450207
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

0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 4

Author Comment

by:CraigLazar
ID: 1450208
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
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1450209
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

0
 

Expert Comment

by:ed209
ID: 1450210
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
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question