form and stuff

in your Class ...
Code:
[COLOR=Blue]Public Class[/COLOR] Class1
    [COLOR=Blue]Public[/COLOR] frm [COLOR=Blue]As[/COLOR] Form1
    [COLOR=Blue]Public[/COLOR] [COLOR=Blue]Sub New[/COLOR]([COLOR=Blue]ByVal[/COLOR] f [COLOR=Blue]As[/COLOR] Form1)
        frm = f
    [COLOR=Blue]End Sub[/COLOR]

    [COLOR=Blue]Public Sub[/COLOR] setLabel([COLOR=Blue]ByVal[/COLOR] strText [COLOR=Blue]As String[/COLOR])
        frm.Label1.Text = strText
    [COLOR=Blue]End Sub[/COLOR]
[COLOR=Blue]End Class[/COLOR]
in your form ( containing the Label ) ...
Code:
    [COLOR=Blue]Private Sub[/COLOR] Button1_Click([COLOR=Blue]ByVal[/COLOR] sender [COLOR=Blue]As[/COLOR] System.Object, [COLOR=Blue]ByVal[/COLOR] e [COLOR=Blue]As[/COLOR] System.EventArgs) [COLOR=Blue]Handles[/COLOR] Button1.Click
        [COLOR=Blue]Dim[/COLOR] cls [COLOR=Blue]As New[/COLOR] Class1([COLOR=Blue]Me[/COLOR])
        cls.setLabel("test 123")
    [COLOR=Blue]End Sub[/COLOR]
 
Public frm As Form1
Public Sub New(ByVal f As Form1)
frm = f
End Sub

Public Sub setLabel(ByVal strText As String)
frm.Label1.Text = strText
End Sub


it doesnt let me write frm.label1 because there isnt such a thing as frm because it is not set ?
 
Ok, I think you misunderstood me ? I mean I want to control class1 labels from my class2 sub programs...without inheriting the whole class1
 
seems like you have really tested it... and i got it to work with empty project.... I have to think how to modify it for my own classes... I think I did something wrong because my class names are a bit dodgy...
 
Back
Top