473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to make vB remember a value between forms?

1
Hi! I'm using a database to store the values for my project. I'm designing a simple payroll.

I want to calculate the gross salary of an employee, to do this I have to get the hourly rate of that person (I have that stored on a table) and multiply it by the total of hours worked (those values I store on a different table).

I'm having problems taking the hourly rate from the other table to do the math calculation. When I input the values into the database I had to do it on another form, and they're on another table so I really have no idea how I should call it. I've tried it several ways but Visual Basic always records it as 0.

Oh... and I wish I could, but I can't make any changes to my database. Teacher's orders. blah. :(

Thanks so much in advance for your help. I wasn't sure what code to paste here so... if you need me to expand more on the problem with some coding let me know. :]
Dec 12 '07 #1
3 1914
Torgg
41
If your using VB6 then you can add a Module to your project and then at the top declare some global variables, like so...

Global MyGlobalVar As String

If your using VB.NET then add a Module to your project and then at the top declare your global variables like so...

Public myGlobalVar As String

This approach stores your values in a central location for use from any form.

I'm not saying that this is good coding practice. I'm only giving you an answer to your question. If you want a more robust method of doing the work then based on your explanation of the project your working on, I would create all the forms required to handle data input and have all that data stored in the database (like you've already done). Then I would create function to retrieve all the data from the database manipulate it then output it to the user. Others here may have better advise.

Hope this helps,
Torgg
Dec 13 '07 #2
debasisdas
8,127 Expert 4TB
You need to declare some public variables.
Dec 13 '07 #3
Yes, Public variables. I had the same problem several years ago, but after creating a module called Variables (Or whatever), I keep all my variable declarations in that module "Public MyVar1, MyVar2, MyVar3 As Single" etc.

Haven't had the problem with forgotten variable values since.

Hope this helped,
Robert
Dec 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Dennis Burdett | last post by:
I have a pretty complex control which use to be a C# windows form that I am trying to make into a control that can be dragged onto a VB6 form. I was able to make it into a com class that I could...
1
by: | last post by:
I'm currently at the Macromedia Max Developer Conference in California and was impressed by vendor's InterAct User Authentication system which bascially allows one to smash together a 'Remember Me'...
27
by: Just Me | last post by:
I made a Usercontrol that must have AutoScroll set to true when it is used. So I set it to True in the Load event. However the property still shows in the properties window when the control is...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
1
by: Ben R. | last post by:
what exactly does this do? does it control whether cookies are persisted between sessions? I aske because the duration a cookie is stored seems to be set in web.config: <authentication...
4
by: Samuel Shulman | last post by:
Hi How can I implement a feature of 'Remember me on this computer' I believe using cookies that next time when the user comes to the login page I can add the Userename to the appropriate Textbox...
1
by: Dabbler | last post by:
I have a login page which requires all users to login everytime they visit, the remember me feature isn't working. We all have cookies and js enabled. Any suggestions on how to diagnose this? ...
2
by: dougloj | last post by:
Hi. I have an ASP.NET application written in C#. To log in, a user must provide their email address and password. I already give the user a "Remember my Email Address" check box. If they check...
2
by: mndprasad | last post by:
Hi friends, Am new to AJAX coding, In my program am going to have two texbox which going to implent AJAX from same table. One box is going to retrieve the value of other and vice...
5
by: programmerboy | last post by:
I never had this kind of issue before and it is completely surprising. I have a usercontrol where I need 2 forms to make 1 form. When I have only 1 form it submits the page to itself. I have spent...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.