?
Solved

Clear Public Property VB.NET

Posted on 2014-11-04
6
Medium Priority
?
183 Views
Last Modified: 2014-11-09
Hi I have an application where I am using Public Property x As String to carry information from one form to another. The issue is when I get back to the beginning it is remembering the values instead of accepting new ones. Is there a way to clear all values of Public Properties on the last form?
0
Comment
Question by:takwirirar
[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
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:ReneD100
ID: 40421701
What do you mean with 'when I get back to the beginning?'
0
 
LVL 1

Author Comment

by:takwirirar
ID: 40421754
I have 7 forms. Step 1, 2, 3 etc. So I could set a Public Property at Step 2 then carry all the way to Step 7 however when I press Finish at Step 7 the application comes back to Step 1 again.
0
 
LVL 5

Expert Comment

by:ReneD100
ID: 40421862
I'm still confused - are we talking about 7 different forms or 7 instances of the same form? And is the property defined on the form or in a separate class? If we have 7 instances, then each instance will have it's 'own' property x and thus it's own value. The fact it is 'public' just means it's accessible from 'outside'. If you need the 7 forms to store in a common variable (and thus overwrite) you could either carry it over when the form gets closed, or you could created an application wide (global) variable. In this case you add a module and define a public string there.
Hope this helps a bit.
0
Independent Software Vendors: 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 63

Expert Comment

by:Fernando Soto
ID: 40421865
Can you post some code to show us what you are doing so that we have a better understanding of your needs.
0
 
LVL 1

Accepted Solution

by:
takwirirar earned 0 total points
ID: 40421938
Hey guys, thanks for all your responses. I just found my error.  I was running my code under Form_Load instead of Form_Activated http://msdn.microsoft.com/en-us/library/system.windows.forms.form.load(v=vs.110).aspx showed me that the Load is only for the first time instead of every time the Form runs.

The erroneous code was

Public Class Step_1
    Public Property ProductType As String

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ProductType = TextBox1.Text
        Me.Hide()
        Step_2.Show()
    End Sub
End Class

Public Class Step_2
    Public Property ProductType As String

    Private Sub Step_2_Load(sender As Object, e As EventArgs) Handles Me.Load
	Label10.Text = Step_1.ProductType

	Me.Hide()
        Step_1.Show()

    End Sub
End Class

Open in new window


Hopefully that make sense
0
 
LVL 1

Author Closing Comment

by:takwirirar
ID: 40431035
Found the error was to do with my code
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

743 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