Hi,

I am brand new to the DaniWeb Forums. I'm also very new to VB, and I taking my first course on it. I nearly have a large project done, but I have one main issue that I have not been able to resolve on my own as of yet.

My issue is that I'm trying to set a final form page that retains the calculated totals from three previous forms within a project. I believe I may need to create a module for this, but I'm not certain of how my code should be stated. I assume that I would chose something that appears to be global and or public in the module for each of the three original forms, and then place a corresponding code in those three original forms. I'm just not sure what type of coding I should be using - I've looked over public variables in my text books but, didn't find anything that work for this project. Would someone mind giving me a sample coding or and idea of where/how I should start this segment? Also not certain if this is relevant, but two of my forms contain radio button controls and one of my forms contains a series of check box forms. Really appreciate any answers/input you can give me on this topic.
Thanks!
Tina

Real simple answer is to add a module and declare your varibles with the Public keyword. Then from each of your forms as you complete your calculations you can assign these/this variable with the result of your calculations. Thus in the next form you should be able to retrieve the valued stored within this/these variables.

However, if you do not want to add a module you can declare a public variable at the top of form1 in the general declarations area. Then you could reference that variable from the other forms via Form1.VariableName = Value or Value = Form1.VariableName as long as you don't unload the form, Hide it until program ends or only unload it after you are done with your calculations.

Good Luck

vb5prgrmr,

First of all thank you for your helpful post and sorry it has taken me a few days to get back to reply.

I still have a questions it isn't completely clear to me. I'm still not exactly sure where I would set a public variable, would I set it up in the mainForm section of each of the codes for the four forms. I hope this isn't too annoying but I'm going to attach my project and if you can give me an example of where I should post public variables that would be very helpful. I assume I would place the variable just below where I would set up options such as explicit, strict, and infer Also I did set up (or am actually in the process of) setting up a previous and forward connect to forms and have set it up so the previous form is hidden, how would this affect the information passing through to the final form. Oh also, when I set up a public variable would I then need to add a structure such as Dim publicTerm As New termInForm1,2,or3?

Thanks very much and if this is too much to ask in a question, I total understand.
Thanks again,
Tina

Hi vb5prgrmr,

I just added a few questions to this discussion. If it is too much info, please let me know.

Thanks,
Tina

Okay, downloaded your project and I see that you are using .NET. This is the "classic" vb forum for versions prior to .net 2k2 (2k3,2k5,2k8,(2k10)). However, what I said before still applies and I think I understand more of what you are asking.

Okay, in classic vb as in .net you can declare a public variable in the general declarations part of a form and then reference it by using...

formname.variablename

via retrieving or setting...

somevariable = formname.variablename

or

formname.variablename = somevalue

just as you would do...

somevariable = DirectoryForm.HayesLabel.Text

Now, as to try to answer your other question...

When a form is hidden and not unloaded everything contained within that form that has been exposed (controls, public variables) are accessible from other forms or modules (don't get confused here, its okay).

I hope this helps clear some thing up.

Good Luck

This question has already been answered. Start a new discussion instead.