jin katama

hello friends

is it correct

form1

Code Block

form1

inherits form2

form2

Code Block

form2

settext() function as friend

when i load the form1 can i call the function settext from the form2

when the form loads can i access the same function without hidding the form1

i mean can i run the two form at a time base class and derived class

i tell u in clearly

i am having two form one having a textbox and command button when i press the command button the text in

the textbox is passed as an arg to the form two function settext() it set the text of label1 in form2 can i see the

changes simulataneously i mean (when i load the form1 it will load the form2) is it possilbe




Re: Visual Basic Express Edition friend function

Dave299

jin katama wrote:

form1

Code Block

form1

inherits form2

You cannot do that, at least not in the way you have shown.

When you create a form in the form designer VB creates a lot of code for you, in Form1.Designer.vb, which you do not normally see. That code contains a line

Inherits System.Windows.Forms.Form

You can only have one Inherits in a class. If you really wanted Form1 to inherit from Form2 then you would need to change that line to inherit from Form2, but I wouldn't recommend you to do that. In any case I don't think that is what you really want.

See my post here

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2360655&SiteID=1

for an example of how to set a label on one form with the text from a textbox on another form. You can easily modify this so it only works when you click a button.





Re: Visual Basic Express Edition friend function

clint 2

dave wrote...

When you create a form in the form designer VB creates a lot of code for you, in Form1.Designer.vb, which you do not normally see. That code contains a line

Inherits System.Windows.Forms.Form

hi dave...

is it possible to view the code that vb creates...and how

cheers

clint






Re: Visual Basic Express Edition friend function

Dave299

Clint

In the Solution Explorer click on Show All Files.

Then expand the form you are interested in.

And to repeat the warning - don't modify it unless you are sure of what you are doing !





Re: Visual Basic Express Edition friend function

clint 2

ok dave, thanks

I seen that before, will have to study it more

cheers






Re: Visual Basic Express Edition friend function

Tall Dude

To add one comment to what Dave said:

Form1.Designer.vb is the VB generated partial class code

for Form1.

It will be a useful file to work with (down the road,)

but you should begin becoming familiar with what is

in it.

In older VB examples you find on the web, these classes

were combined into one file.

http://www.codenotes.com/articles/articleAction.aspx articleID=528

is an example of this.

As you progress, you will be able to 'fix up' these type old

examples by understanding the 'partial class / 2 file' way

things are done now.

You can also still combine Form1.vb and Form1.Designer.vb into

one file (Form1.vb) in VB express.

(You would then end up deleting the Form1.Designer.vb file.

This is not recommended in most situations or for non-advanced

programmers!)