forms as arguments in procedures

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In visual basic 6 I was able to do the following:

ABCProc(Me)

sub ABCProc(frm as form)
....
rowTopics.ParentID = CInt(frm.txtParentID.Text)
etc.

In vb net when I pass the form the controls on it don't
come with it so I can't create a new row by the values in
controls on another form. That would vastly reduce the
amount of code I have to write to produce generic
routines.

Can somebody help. I've looked in four books and
searched msdn without results.

dennist
 
You cant see the controls on the form because:
a. you send in a generic form object and not the exact type of the
form that the procedure expects (so if your form class is calle
"MyForm" your sub should expect "f as MyForm")

b. The controls on the form are declared as "Friend" so if the
procedure that you are sending your form to is declared as part of the
same class as your form, you'll be able to see them. If you're sending
this to a differnet class , you need to change the declaratins of the
controls on your form from Friend to "Public". That should do the
trick.

Notice, hoever that it's not a good idea to expose your controls as
public members because it violates some of the OOP rules. It's better
to create public methods on your form to manipulate any child
controls.
 
Thanks for Roy's reponse.

Hi DennisT,

Just as Roy said, the Modifiers property of a control is set to "private"
by default. If you want to access it from outside of this class, you have
to set it to "public". You can set it in the property windows in VS.net or
manually modify it in code.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: Roy Osherove <[email protected]>
| Subject: Re: forms as arguments in procedures
| Date: Thu, 06 Nov 2003 15:22:10 +0200
| Message-ID: <[email protected]>
| References: <[email protected]>
| X-Newsreader: Forte Agent 1.93/32.576 English (American)
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: dsl212-235-74-14.bb.netvision.net.il 212.235.74.14
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65629
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| You cant see the controls on the form because:
| a. you send in a generic form object and not the exact type of the
| form that the procedure expects (so if your form class is calle
| "MyForm" your sub should expect "f as MyForm")
|
| b. The controls on the form are declared as "Friend" so if the
| procedure that you are sending your form to is declared as part of the
| same class as your form, you'll be able to see them. If you're sending
| this to a differnet class , you need to change the declaratins of the
| controls on your form from Friend to "Public". That should do the
| trick.
|
| Notice, hoever that it's not a good idea to expose your controls as
| public members because it violates some of the OOP rules. It's better
| to create public methods on your form to manipulate any child
| controls.
|
| ---
| Regards,
|
| Roy Osherove
| www.iserializable.com
|
| >In visual basic 6 I was able to do the following:
| >
| >ABCProc(Me)
| >
| >sub ABCProc(frm as form)
| >...
| >rowTopics.ParentID = CInt(frm.txtParentID.Text)
| >etc.
| >
| >In vb net when I pass the form the controls on it don't
| >come with it so I can't create a new row by the values in
| >controls on another form. That would vastly reduce the
| >amount of code I have to write to produce generic
| >routines.
| >
| >Can somebody help. I've looked in four books and
| >searched msdn without results.
| >
| >dennist
|
|
 
Kevin thank you as usual. You and other Microsoft representatives fill
in what the books don't. This is helpful to me. I am 100% disabled and
programming is among the few pleasures I have. Your help makes the
excellent value of a universal subscription(paid for by my cousin) worth
much more.

I have to go to the clinic for intravenous antibiotics this morning.
I'll leave when the cleaner arrives to prepare for Shabbat, and will try
your suggestions when I get back. Thanks for the tip on the property
pages. Much safer than playing around in the windows section code.

dennist
 
Thank you Dennis for your compliment. Satisfying customer is my top
priority. If you have any further questions, please feel free to post them
in the newsgroup. I'll be glad if I can help.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: dennis turner <[email protected]>
| References: <[email protected]>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Re: forms as arguments in procedures
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Date: Thu, 06 Nov 2003 21:07:58 -0800
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65721
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
|
| Kevin thank you as usual. You and other Microsoft representatives fill
| in what the books don't. This is helpful to me. I am 100% disabled and
| programming is among the few pleasures I have. Your help makes the
| excellent value of a universal subscription(paid for by my cousin) worth
| much more.
|
| I have to go to the clinic for intravenous antibiotics this morning.
| I'll leave when the cleaner arrives to prepare for Shabbat, and will try
| your suggestions when I get back. Thanks for the tip on the property
| pages. Much safer than playing around in the windows section code.
|
| dennist
|
|
|
| Don't just participate in USENET...get rewarded for it!
|
 
Thanks both Roy and Kevin,

I changed two controls on the form to public. I call the
class using form named Me. the forms actual name is
form1. In the class sub I have the argument frm as
form1. Using either frm or form1, and then type "."
neither of the controls appear. So it doesn't seem to
work, or there is something I'm doing wrong.

Any suggestions?

dennist
-----Original Message-----
You cant see the controls on the form because:
a. you send in a generic form object and not the exact type of the
form that the procedure expects (so if your form class is calle
"MyForm" your sub should expect "f as MyForm")

b. The controls on the form are declared as "Friend" so if the
procedure that you are sending your form to is declared as part of the
same class as your form, you'll be able to see them. If you're sending
this to a differnet class , you need to change the declaratins of the
controls on your form from Friend to "Public". That should do the
trick.

Notice, hoever that it's not a good idea to expose your controls as
public members because it violates some of the OOP rules. It's better
to create public methods on your form to manipulate any child
controls.
 
tried every variation I could think of. If I leave the
form in as a calling argument in the form calling the
class, whether me or form1 or tfsnet2.form1, it is
underlined with the message:

'form1' is a type in 'tfsnet2' and cannot be used in an
expression.

If I remove the form name as an argument, and whether or
not I leave the argument is the sub name in the class,
when I make the statement form1 or tfsnet2.form I, the
controls do not appear.

dennist
]
I looked in the windows designer generated code and the
control names are indeed modified with the public keyword.

-----Original Message-----
You cant see the controls on the form because:
a. you send in a generic form object and not the exact type of the
form that the procedure expects (so if your form class is calle
"MyForm" your sub should expect "f as MyForm")

b. The controls on the form are declared as "Friend" so if the
procedure that you are sending your form to is declared as part of the
same class as your form, you'll be able to see them. If you're sending
this to a differnet class , you need to change the declaratins of the
controls on your form from Friend to "Public". That should do the
trick.

Notice, hoever that it's not a good idea to expose your controls as
public members because it violates some of the OOP rules. It's better
to create public methods on your form to manipulate any child
controls.
 
Thanks Roy and Kevin.

I changed two controls to public and explicitly changed
the sub the public sub.

I tried with the forms in the aruments lists and with the
forms removed from the argument lists.

I tried form1. and tfsnet2.form1


but the sub did not see the controls.

any further ideas?

dennist
-----Original Message-----
Thanks for Roy's reponse.

Hi DennisT,

Just as Roy said, the Modifiers property of a control is set to "private"
by default. If you want to access it from outside of this class, you have
to set it to "public". You can set it in the property windows in VS.net or
manually modify it in code.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: Roy Osherove <[email protected]>
| Subject: Re: forms as arguments in procedures
| Date: Thu, 06 Nov 2003 15:22:10 +0200
| Message-ID:
| References: <[email protected]>
| X-Newsreader: Forte Agent 1.93/32.576 English (American)
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: dsl212-235-74-
14.bb.netvision.net.il 212.235.74.14
 
Hi Dennis,

From the error message, we can see that fom2 is not a valid object
reference, but the name of a type (class name). So you have to instantiate
from2 class before passing it as a parameter to the sub. Here's an example:

Dim f2 as form2
rowTopics.ParentID = CInt(f2.txtParentID.Text)

HTH. If anything is unclear, please feel free to reply to the post. I'll be
glad to help.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: <[email protected]>
| Sender: <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: forms as arguments in procedures
| Date: Fri, 7 Nov 2003 02:03:32 -0800
| Lines: 78
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOlFma3VWLuSepSThSnbpJTZVBLfA==
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65735
| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| tried every variation I could think of. If I leave the
| form in as a calling argument in the form calling the
| class, whether me or form1 or tfsnet2.form1, it is
| underlined with the message:
|
| 'form1' is a type in 'tfsnet2' and cannot be used in an
| expression.
|
| If I remove the form name as an argument, and whether or
| not I leave the argument is the sub name in the class,
| when I make the statement form1 or tfsnet2.form I, the
| controls do not appear.
|
| dennist
| ]
| I looked in the windows designer generated code and the
| control names are indeed modified with the public keyword.
|
|
| >-----Original Message-----
| >You cant see the controls on the form because:
| >a. you send in a generic form object and not the exact
| type of the
| >form that the procedure expects (so if your form class
| is calle
| >"MyForm" your sub should expect "f as MyForm")
| >
| >b. The controls on the form are declared as "Friend" so
| if the
| >procedure that you are sending your form to is declared
| as part of the
| >same class as your form, you'll be able to see them. If
| you're sending
| >this to a differnet class , you need to change the
| declaratins of the
| >controls on your form from Friend to "Public". That
| should do the
| >trick.
| >
| >Notice, hoever that it's not a good idea to expose your
| controls as
| >public members because it violates some of the OOP
| rules. It's better
| >to create public methods on your form to manipulate any
| child
| >controls.
| >
| >---
| >Regards,
| >
| >Roy Osherove
| >www.iserializable.com
| >On Thu, 6 Nov 2003 01:54:52 -0800,
| >
| >>In visual basic 6 I was able to do the following:
| >>
| >>ABCProc(Me)
| >>
| >>sub ABCProc(frm as form)
| >>...
| >>rowTopics.ParentID = CInt(frm.txtParentID.Text)
| >>etc.
| >>
| >>In vb net when I pass the form the controls on it don't
| >>come with it so I can't create a new row by the values
| in
| >>controls on another form. That would vastly reduce the
| >>amount of code I have to write to produce generic
| >>routines.
| >>
| >>Can somebody help. I've looked in four books and
| >>searched msdn without results.
| >>
| >>dennist
| >
| >.
| >
|
 
Thanks Roy and Kevin.

I changed two controls to public and explicitly changed
the sub the public sub.

I tried with the forms in the aruments lists and with the
forms removed from the argument lists.

I tried form1. and tfsnet2.form1

but the sub did not see the controls.

any further ideas?

dennist
[6 quoted lines suppressed] set to "private"
[1 quoted line suppressed] this class, you have
[1 quoted line suppressed] windows in VS.net or
[3 quoted lines suppressed] post.
[4 quoted lines suppressed] and confers no
[7 quoted lines suppressed]
[2 quoted lines suppressed] (American)
[5 quoted lines suppressed]
14.bb.netvision.net.il 212.235.74.14
[2 quoted lines suppressed] TK2MSFTNGP12.phx.gbl
[1 quoted line suppressed] microsoft.public.dotnet.framework.adonet:65629
[4 quoted lines suppressed] type of the
[1 quoted line suppressed] is calle
[3 quoted lines suppressed] so if the
[1 quoted line suppressed] declared as part of the
[1 quoted line suppressed] If you're sending
[1 quoted line suppressed] declaratins of the
[1 quoted line suppressed] should do the
[3 quoted lines suppressed] your controls as
[1 quoted line suppressed] rules. It's better
[1 quoted line suppressed] any child
[8 quoted lines suppressed]
[11 quoted lines suppressed] don't
[1 quoted line suppressed] values in
[1 quoted line suppressed] the
[12 quoted lines suppressed]

Did you remember to accept as an argument to the sub a form type of your
form, and NOT a generic Form object?
 
The plot thickens.

I shouldn't have been using form1 as an argument at all.
The calling form is TopicFromStart.

Now, when I do what Kevin just suggested, and instantiate
the form before calling the procedure, I get the
following error message.

Dim tfs1 As TopicFromStart

type 'topicfromstart' is not defined.

If I don't instantiate it, and type me in the call to the
procedure, I get

ByVal frm As topicfromstart
type 'topicfromstart' is not defined.

Oi ve voi. What to do?

dennist
 
Hi Dennis,

Please try to check if the defination of TopicFromStart is in the same
namespace as where you call it. If not, please add namespace before
TopicFromStart. Like: namespace.TopicFromStart. If that still cannot work,
is it convenient for you to send your project to my mail box? I'll try my
best to help you if I can see the code. I think you know my email address.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: "dennist" <[email protected]>
| Sender: "dennist" <[email protected]>
| References: <[email protected]>
| Subject: forms as arguments in procedures
| Date: Mon, 10 Nov 2003 01:45:06 -0800
| Lines: 22
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOnb1KV9PKU66iWTgODB/5cOoJnjw==
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65905
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| The plot thickens.
|
| I shouldn't have been using form1 as an argument at all.
| The calling form is TopicFromStart.
|
| Now, when I do what Kevin just suggested, and instantiate
| the form before calling the procedure, I get the
| following error message.
|
| Dim tfs1 As TopicFromStart
|
| type 'topicfromstart' is not defined.
|
| If I don't instantiate it, and type me in the call to the
| procedure, I get
|
| ByVal frm As topicfromstart
| type 'topicfromstart' is not defined.
|
| Oi ve voi. What to do?
|
| dennist
|
 
Hi Dennis,

It seems that the class name of the form is "frmTopicFromStart". To get a
good view of all the class names and their members, you can use Class View.
To enable it, just choose Class View from the View menu. Every class in
your project will be listed in a tree view.

Further more, you have to create an instance of that form. If not, the tfs1
will become a null reference, because it doesn't points a valid object. A
NullReferenceException might be throw when you're trying to use that
object. So we have to create a new instance before using it. Your code
might have to be look like the following:

Dim tfs1 As New frmTopicFromStart
ABCProc(tfs1)

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: "dennist" <[email protected]>
| Sender: "dennist" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
| Subject: RE: forms as arguments in procedures
| Date: Mon, 10 Nov 2003 20:51:33 -0800
| Lines: 78
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOoD3sFRm1dCn2NQIWVlVCT+RCBlA==
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65976
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| Kevin, I sent the project.
|
| thanks,
|
| dennist
| >-----Original Message-----
| >Hi Dennis,
| >
| >Please try to check if the defination of TopicFromStart
| is in the same
| >namespace as where you call it. If not, please add
| namespace before
| >TopicFromStart. Like: namespace.TopicFromStart. If that
| still cannot work,
| >is it convenient for you to send your project to my mail
| box? I'll try my
| >best to help you if I can see the code. I think you know
| my email address.
| >
| >Kevin Yu
| >=======
| >"This posting is provided "AS IS" with no warranties,
| and confers no
| >rights."
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "dennist" <[email protected]>
| >| Sender: "dennist" <[email protected]>
| >| References: <[email protected]>
| >| Subject: forms as arguments in procedures
| >| Date: Mon, 10 Nov 2003 01:45:06 -0800
| >| Lines: 22
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Thread-Index: AcOnb1KV9PKU66iWTgODB/5cOoJnjw==
| >| Newsgroups: microsoft.public.dotnet.framework.adonet
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.adonet:65905
| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| >| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| >|
| >| The plot thickens.
| >|
| >| I shouldn't have been using form1 as an argument at
| all.
| >| The calling form is TopicFromStart.
| >|
| >| Now, when I do what Kevin just suggested, and
| instantiate
| >| the form before calling the procedure, I get the
| >| following error message.
| >|
| >| Dim tfs1 As TopicFromStart
| >|
| >| type 'topicfromstart' is not defined.
| >|
| >| If I don't instantiate it, and type me in the call to
| the
| >| procedure, I get
| >|
| >| ByVal frm As topicfromstart
| >| type 'topicfromstart' is not defined.
| >|
| >| Oi ve voi. What to do?
| >|
| >| dennist
| >|
| >
| >.
| >
|
 
I followed your advice and the testsub definitely sees
the controls on the calling form. However, there is
still a problem.

In the button click event procedure that calls the sub, I
first check that the comboboxes all have selected
values. For example, below.


ElseIf cboDateType.SelectedIndex = -1 Then
MsgBox("No Date Type is selected.")
cboDateType.Focus()
Exit Sub

Public Sub TestFormPass(ByVal frm As
frmTopicFromStart)
Dim s As String
s = CStr(frm.cboDateType.SelectedIndex)
MsgBox(s)
End

yet the message box in the called form gives an index of -
1.

Something else may be related. I instantiate frmTopic
from start with dim tfs1 as new frmtopicfromstart.

I put tfs1 into the call to the test sub.

However, when I tried to put frm as tfs1 in the called
procedure's argument list, I got a message that tfs1 is
not defined. When I put in frm as frmtopicfrom start it
was accepted fine.

Any further advice in this never ending soap opera?

thank you for your time.

dennist
-----Original Message-----
Hi Dennis,

It seems that the class name of the form
is "frmTopicFromStart". To get a
 
Hi Dennis,

I've checked your code and made some changes to it. The NewTopic method now
only requires one parameter whose which is a form type. I've also sent you
an email with the code.

If anything is unclear, please feel free to let me know.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| Content-Class: urn:content-classes:message
| From: "dennist" <[email protected]>
| Sender: "dennist" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: RE: forms as arguments in procedures
| Date: Tue, 11 Nov 2003 00:54:47 -0800
| Lines: 184
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOoMXU5XyMQsSgYTRGf7r6K1ysm3g==
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:65991
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I followed your advice and the testsub definitely sees
| the controls on the calling form. However, there is
| still a problem.
|
| In the button click event procedure that calls the sub, I
| first check that the comboboxes all have selected
| values. For example, below.
|
|
| ElseIf cboDateType.SelectedIndex = -1 Then
| MsgBox("No Date Type is selected.")
| cboDateType.Focus()
| Exit Sub
|
| Public Sub TestFormPass(ByVal frm As
| frmTopicFromStart)
| Dim s As String
| s = CStr(frm.cboDateType.SelectedIndex)
| MsgBox(s)
| End
|
| yet the message box in the called form gives an index of -
| 1.
|
| Something else may be related. I instantiate frmTopic
| from start with dim tfs1 as new frmtopicfromstart.
|
| I put tfs1 into the call to the test sub.
|
| However, when I tried to put frm as tfs1 in the called
| procedure's argument list, I got a message that tfs1 is
| not defined. When I put in frm as frmtopicfrom start it
| was accepted fine.
|
| Any further advice in this never ending soap opera?
|
| thank you for your time.
|
| dennist
| >-----Original Message-----
| >Hi Dennis,
| >
| >It seems that the class name of the form
| is "frmTopicFromStart". To get a
| >good view of all the class names and their members, you
| can use Class View.
| >To enable it, just choose Class View from the View menu.
| Every class in
| >your project will be listed in a tree view.
| >
| >Further more, you have to create an instance of that
| form. If not, the tfs1
| >will become a null reference, because it doesn't points
| a valid object. A
| >NullReferenceException might be throw when you're trying
| to use that
| >object. So we have to create a new instance before using
| it. Your code
| >might have to be look like the following:
| >
| >Dim tfs1 As New frmTopicFromStart
| >ABCProc(tfs1)
| >
| >Kevin Yu
| >=======
| >"This posting is provided "AS IS" with no warranties,
| and confers no
| >rights."
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "dennist" <[email protected]>
| >| Sender: "dennist" <[email protected]>
| >| References: <[email protected]>
| ><[email protected]>
| ><[email protected]>
| >| Subject: RE: forms as arguments in procedures
| >| Date: Mon, 10 Nov 2003 20:51:33 -0800
| >| Lines: 78
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Thread-Index: AcOoD3sFRm1dCn2NQIWVlVCT+RCBlA==
| >| Newsgroups: microsoft.public.dotnet.framework.adonet
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.framework.adonet:65976
| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| >|
| >| Kevin, I sent the project.
| >|
| >| thanks,
| >|
| >| dennist
| >| >-----Original Message-----
| >| >Hi Dennis,
| >| >
| >| >Please try to check if the defination of
| TopicFromStart
| >| is in the same
| >| >namespace as where you call it. If not, please add
| >| namespace before
| >| >TopicFromStart. Like: namespace.TopicFromStart. If
| that
| >| still cannot work,
| >| >is it convenient for you to send your project to my
| mail
| >| box? I'll try my
| >| >best to help you if I can see the code. I think you
| know
| >| my email address.
| >| >
| >| >Kevin Yu
| >| >=======
| >| >"This posting is provided "AS IS" with no warranties,
| >| and confers no
| >| >rights."
| >| >
| >| >--------------------
| >| >| Content-Class: urn:content-classes:message
| >| >| From: "dennist" <[email protected]>
| >| >| Sender: "dennist" <[email protected]>
| >| >| References: <082701c3a44c$06267800
| [email protected]>
| >| >| Subject: forms as arguments in procedures
| >| >| Date: Mon, 10 Nov 2003 01:45:06 -0800
| >| >| Lines: 22
| >| >| Message-ID: <[email protected]>
| >| >| MIME-Version: 1.0
| >| >| Content-Type: text/plain;
| >| >| charset="iso-8859-1"
| >| >| Content-Transfer-Encoding: 7bit
| >| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
| >| V5.50.4910.0300
| >| >| Thread-Index: AcOnb1KV9PKU66iWTgODB/5cOoJnjw==
| >| >| Newsgroups: microsoft.public.dotnet.framework.adonet
| >| >| Path: cpmsftngxa06.phx.gbl
| >| >| Xref: cpmsftngxa06.phx.gbl
| >| microsoft.public.dotnet.framework.adonet:65905
| >| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| >| >| X-Tomcat-NG:
| microsoft.public.dotnet.framework.adonet
| >| >|
| >| >| The plot thickens.
| >| >|
| >| >| I shouldn't have been using form1 as an argument at
| >| all.
| >| >| The calling form is TopicFromStart.
| >| >|
| >| >| Now, when I do what Kevin just suggested, and
| >| instantiate
| >| >| the form before calling the procedure, I get the
| >| >| following error message.
| >| >|
| >| >| Dim tfs1 As TopicFromStart
| >| >|
| >| >| type 'topicfromstart' is not defined.
| >| >|
| >| >| If I don't instantiate it, and type me in the call
| to
| >| the
| >| >| procedure, I get
| >| >|
| >| >| ByVal frm As topicfromstart
| >| >| type 'topicfromstart' is not defined.
| >| >|
| >| >| Oi ve voi. What to do?
| >| >|
| >| >| dennist
| >| >|
| >| >
| >| >.
| >| >
| >|
| >
| >.
| >
|
 
Back
Top