Solved

Simple Ques on Variables

Posted on 1998-12-15
6
133 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
Comment Utility
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
Comment Utility
is it in the declarations section?
0
 
LVL 12

Expert Comment

by:mark2150
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Author Comment

by:CraigLazar
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now