Solved

Clear Public Property VB.NET

Posted on 2014-11-04
6
180 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
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!

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

707 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