Solved

Clear Public Property VB.NET

Posted on 2014-11-04
6
164 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 62

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now