Hi,
I have a situation where I have a Windows Form and I have 2 classes defined
in the code, the primary form and a class that I got from the internet. I
have a label in the form that I would like the 2nd class to write to...so I
declared the label as "Public Shared". Which worked, I can write to it.
But I get an error when closing down visual studio, it says the label was
never declared and when i reopen Visual the label has disappeared off of the
form. When I go to put it back I get an error saying it already exists.
What is going on here? I simply need to write text to a label in the form
from a class.
Structure:
Public Class DTSConvertor725
Inherits System.Windows. Forms.Form
'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents OpenFileDialog1 As System.Windows. Forms.OpenFileD ialog
Friend WithEvents TestSQLConnecti on As System.Windows. Forms.Button
Public Shared label1 As System.Windows. Forms.Label
<code goes here>
End Class
Public Class PackageEventsSi nk
Inherits System.Windows. Forms.Form
Implements DTS.PackageEven ts
Public fParentForm As DTSConvertor725
Overridable Overloads Sub OnStart(ByVal EventSource As String) _
Implements DTS.PackageEven ts.OnStart
Console.WriteLi ne("START in {0}", EventSource)
fParentForm.Ste pCount = fParentForm.Ste pCount + 1
fParentForm.lab el1.Text = "Step " & fParentForm.Ste pCount & " " &
EventSource
System.Windows. Forms.Applicati on.DoEvents()
End Sub
End Class
I have a situation where I have a Windows Form and I have 2 classes defined
in the code, the primary form and a class that I got from the internet. I
have a label in the form that I would like the 2nd class to write to...so I
declared the label as "Public Shared". Which worked, I can write to it.
But I get an error when closing down visual studio, it says the label was
never declared and when i reopen Visual the label has disappeared off of the
form. When I go to put it back I get an error saying it already exists.
What is going on here? I simply need to write text to a label in the form
from a class.
Structure:
Public Class DTSConvertor725
Inherits System.Windows. Forms.Form
'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents OpenFileDialog1 As System.Windows. Forms.OpenFileD ialog
Friend WithEvents TestSQLConnecti on As System.Windows. Forms.Button
Public Shared label1 As System.Windows. Forms.Label
<code goes here>
End Class
Public Class PackageEventsSi nk
Inherits System.Windows. Forms.Form
Implements DTS.PackageEven ts
Public fParentForm As DTSConvertor725
Overridable Overloads Sub OnStart(ByVal EventSource As String) _
Implements DTS.PackageEven ts.OnStart
Console.WriteLi ne("START in {0}", EventSource)
fParentForm.Ste pCount = fParentForm.Ste pCount + 1
fParentForm.lab el1.Text = "Step " & fParentForm.Ste pCount & " " &
EventSource
System.Windows. Forms.Applicati on.DoEvents()
End Sub
End Class
Comment