Solved

Simple Ques on Variables

Posted on 1998-12-15
6
138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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