Home All Groups Group Topic Archive Search About

How to gain access to objet in different class ?

Author
26 Jun 2006 1:12 PM
aurora10
Can ant body help me to see how to get access to all controls of the
Form for Sub in a different class.

Thanks in advance.

this is how it looks:

////////////////////////////////////////
Form1
...........
..........

pirvate sub ButtonClick(.......)

dim A as X = new X
A.Write()
end sub

---------------------
//////////////////////////--------------------
Class X
inherits Form1

public sub ()
Code for Write()

.............

Form1.textbox1........
Form1.textbox2.......
Form1.textbox3.......
etc

//it works OK if I put this Form1 before every textbox but I have them
more than 50 !

if i dont - it doesnt work ( but I put inherits Form1 there !)

How can I work this out without manualy typing every time Form1 ?

.....
end sub
end class
//////////////////////////////////////

Author
26 Jun 2006 3:11 PM
ChristopherJ
okay .... you could try using the "with" keyword
   With Form1
            textbox1
   end with

-ChristopherJ




auror***@gmail.com wrote:
Show quoteHide quote
> Can ant body help me to see how to get access to all controls of the
> Form for Sub in a different class.
>
> Thanks in advance.
>
> this is how it looks:
>
> ////////////////////////////////////////
> Form1
> ..........
> .........
>
> pirvate sub ButtonClick(.......)
>
> dim A as X = new X
> A.Write()
> end sub
>
> ---------------------
> //////////////////////////--------------------
> Class X
> inherits Form1
>
> public sub ()
> Code for Write()
>
> ............
>
> Form1.textbox1........
> Form1.textbox2.......
> Form1.textbox3.......
> etc
>
> //it works OK if I put this Form1 before every textbox but I have them
> more than 50 !
>
> if i dont - it doesnt work ( but I put inherits Form1 there !)
>
> How can I work this out without manualy typing every time Form1 ?
>
> ....
> end sub
> end class
> //////////////////////////////////////
Author
27 Jun 2006 12:58 PM
aurora10
Thank you for reply. It doesn't work that way. Still need to add Form1
before the controls to make it work.

Public Class Class1
    Public Sub Yo()
        With Form1
            Form1.TextBox1.AppendText(".........") < hier
        End With

    End Sub


End Class

-------------------------------------------------------------------------------------------

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

        Dim x As Class1 = New Class1
        x.Yo()


    End Sub
End Class

I simlpify it just to describe the problem...
Author
27 Jun 2006 4:52 PM
William LaMartin
How about changing textbox1 to .textbox1 in the suggestion?

Show quoteHide quote
"ChristopherJ" <cmj***@gmail.com> wrote in message
news:1151334705.243868.146440@m73g2000cwd.googlegroups.com...
> okay .... you could try using the "with" keyword
>   With Form1
>            textbox1
>   end with
>
> -ChristopherJ
>
>
>
>
> auror***@gmail.com wrote:
>> Can ant body help me to see how to get access to all controls of the
>> Form for Sub in a different class.
>>
>> Thanks in advance.
>>
>> this is how it looks:
>>
>> ////////////////////////////////////////
>> Form1
>> ..........
>> .........
>>
>> pirvate sub ButtonClick(.......)
>>
>> dim A as X = new X
>> A.Write()
>> end sub
>>
>> ---------------------
>> //////////////////////////--------------------
>> Class X
>> inherits Form1
>>
>> public sub ()
>> Code for Write()
>>
>> ............
>>
>> Form1.textbox1........
>> Form1.textbox2.......
>> Form1.textbox3.......
>> etc
>>
>> //it works OK if I put this Form1 before every textbox but I have them
>> more than 50 !
>>
>> if i dont - it doesnt work ( but I put inherits Form1 there !)
>>
>> How can I work this out without manualy typing every time Form1 ?
>>
>> ....
>> end sub
>> end class
>> //////////////////////////////////////
>
Author
30 Jun 2006 2:33 PM
aurora10
Thank you thank you thank you

it worked with .