Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple Ques on Variables

Posted on 1998-12-15
6
Medium Priority
?
141 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 40 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

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!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

718 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