Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a Single value from another form

Status
Not open for further replies.

tutuster

Programmer
Feb 2, 2005
41
FI
Situation:

A form has various Single-typed values, the number of these values is dynamic, there might be only 1 or 1000 of these values.

The values are shown in the form on a label or some other component such as textbox. The click event of the component opens up another form, where the value can be changed by typing the new value to a txtbox and clicking a button

I would need to get some hints how to change this value from the other form, should I use the ByRef-statement? How can I change the value?

Short: How can I refer to a value on another form?
 
Resolved the issue by using objects/property.

However, that seems a bit clumsy, there must be a better way to do this, or is there?
 
There is a FAQ that covers some of this.

If you pass a reference of the original form to the new form (or use the me.parentform member for windows opened modally) you can access all of the public properties that form has available. So if you made a public property for each of your values, and then gave the second form access to that object, then that would be an excellent solution.

Another option, like vlad mentioned, would be to use custom events on the child form, and handle those events on the parent form. You can then pass the new value in the event args variable. This is also a great solution.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top